mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
- Updated example in documentation
- Updated imports of Angular request
This commit is contained in:
parent
a8c2ca0cba
commit
5c45280bc7
@ -49,6 +49,8 @@ Inside the component you can inject the service and just use it as you would wit
|
||||
|
||||
```typescript
|
||||
import { Component } from '@angular/core';
|
||||
import { throwError} from 'rxjs';
|
||||
import { catchError, map, retry } from 'rxjs/operators';
|
||||
|
||||
import type { OrganizationService } from './generated/services/OrganizationService';
|
||||
|
||||
@ -59,7 +61,7 @@ import type { OrganizationService } from './generated/services/OrganizationServi
|
||||
export class AppComponent {
|
||||
constructor(private readonly organizationService: OrganizationService) {
|
||||
|
||||
// Make a call
|
||||
// Supports making a simple call
|
||||
this.organizationService
|
||||
.createOrganization({
|
||||
name: 'OrgName',
|
||||
@ -69,12 +71,15 @@ export class AppComponent {
|
||||
console.log(organization);
|
||||
});
|
||||
|
||||
// Or even map result and retry on error
|
||||
// Or creating flows with rety(), catchError() and map()
|
||||
this.organizationService
|
||||
.getOrganizations()
|
||||
.pipe(
|
||||
retry(3),
|
||||
catchError(error =>
|
||||
throwError(error)
|
||||
),
|
||||
map(organizations => organizations[0]),
|
||||
retryWhen(error => error)
|
||||
)
|
||||
.subscribe(organization => {
|
||||
console.log(organization);
|
||||
|
||||
@ -2,7 +2,8 @@
|
||||
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import type { HttpResponse, HttpErrorResponse } from '@angular/common/http';
|
||||
import { catchError, forkJoin, map, switchMap, of, throwError } from 'rxjs';
|
||||
import { forkJoin, of, throwError } from 'rxjs';
|
||||
import { catchError, map, switchMap } from 'rxjs/operators';
|
||||
import type { Observable } from 'rxjs';
|
||||
|
||||
import { ApiError } from './ApiError';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user