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
First of all, great work, saves a bunch of work on my side 👍
What I'm unable to figure out is how to retry a request.
For example I have the following, a class that extends Resource which overrides
getHeaders (to implement the bearer token)
getUrl (to get the baseUrl from the environment)
handleSuccessResponse (to hide the loading bar)
handleErrorResponse (to hide the loading bar and on 401 do a refresh of the bearer token and logout upon 403)
After refreshing the bearer token (which returns a boolean) I would like to re-execute the original request so the user doesn't have to click the button twice.
How would I go and achieve that? Is there a way to send the original request back to this.requestHandler? Or is there some other way?
Below the handleErrorResponse method
$handleErrorResponse(options: IResourceActionInner,resp: IResourceResponse): any {this.loader.complete();switch(resp.status){case401:
if(this._authservice.refresh()){console.log('gotta retry request, but how?');}break;case403:
this._authservice.logout();break;}if(options.returnData&&this.$_canSetInternalData(options)){options.returnData.$resolved=true;}if(options.actionAttributes.onError){options.actionAttributes.onError(resp);}}
The text was updated successfully, but these errors were encountered:
Thank you for warm words :)
It's a log time I did not develop with the library since I switched to Flutter.
But I think you can try to call return this.$restAction(options) in that case (not sure).
$handleErrorResponse(options: IResourceActionInner,resp: IResourceResponse): any {this.loader.complete();switch(resp.status){case401:
if(this._authservice.refresh()){console.log('gotta retry request, but how?');returnthis.$restAction(options);// hope it will help you}break;case403:
this._authservice.logout();break;}if(options.returnData&&this.$_canSetInternalData(options)){options.returnData.$resolved=true;}if(options.actionAttributes.onError){options.actionAttributes.onError(resp);}}
First of all, great work, saves a bunch of work on my side 👍
What I'm unable to figure out is how to retry a request.
For example I have the following, a class that extends Resource which overrides
After refreshing the bearer token (which returns a boolean) I would like to re-execute the original request so the user doesn't have to click the button twice.
How would I go and achieve that? Is there a way to send the original request back to
this.requestHandler
? Or is there some other way?Below the handleErrorResponse method
The text was updated successfully, but these errors were encountered: