@Error( ( apiService: ApiService, error: HttpErrorResponse, _, caught: Observable<any> ) =>
{
if ( error.status === 401 ) // clear login, re-login and replay
return apiService.clearToken().token( … ).pipe( switchMap( () => caught ) );
return throwError( () => error );
} )
export class ApiService extends AbstractApiClient
{
@Cache( Infinity )
@POST( 'http://some.location/authenticate' )
token( @Body( 'username') username: string, @Body( 'password') password: string ): Observable<HttpResponse<any>> { return NEVER; }
@CacheClear<ApiService>( 'token' )
clearToken() { return this; }
@Headers( ( apiService: ApiService ) => apiService.token() )
@POST( 'http://some.location/list' )
list(): Observable<any[]> {
…
}
-
Notifications
You must be signed in to change notification settings - Fork 0
gizm0bill/gzm
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published