You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code snippet will introduce a race condition, should one try to call SomeRESTClient before the _session has been populated, by the createSession request.
Async interceptor could be important for OAuth process, which can has temporary token, needed to update before sending request
Could you also pass Response to responseInterceptor instead of Observable
Here is small example of async interceptor.
@Injectable()
@BaseUrl('https://api.someplace.com')
@DefaultHeaders({'Accept': 'application/json','Content-Type': 'application/json'})exportclassSomeRESTClientextendsRESTClient{constructor(
@Inject(Http)http: Http
@Inject(AuthService)privateauth: AuthService){super(http)this.setup()}protectedrequestInterceptor(req: Request): Promise<void>{returnthis.auth.token(token=>{req.headers.append('Autorization',`Bearer ${token}`)})}protectedresponseInterceptor(res: Response): Promise<void>{// do some stuff with raw response}}
The following code snippet will introduce a race condition, should one try to call SomeRESTClient before the _session has been populated, by the
createSession
request.We should add the possibility to have the requestInterceptor return a promise or similar.
The text was updated successfully, but these errors were encountered: