AddErrorInterceptor: response.status is undefined
See original GitHub issueHi,
Same problem as #44. Here my code:
...
RestangularModule.forRoot([Http], (RestangularProvider, http) => {
RestangularProvider.setBaseUrl('/server');
// This function must return observable
var csrf = "";
var refreshAccesstoken = function () {
//RestangularProvider.setDefaultHeaders({'X-CSRF-Token': csrf});
//http.get('/server/csrfToken').toPromise().then((res) => res.json()._csrf).catch(this.handleError);
// Here you can make action before repeated request
return http.get('/server/csrfToken');
};
console.log("OUI0");
RestangularProvider.addErrorInterceptor((response, subject, responseHandler) => {
console.log(Object.keys(response), response.status, response);
if (response.status === 403) {
console.log("OUI2");
refreshAccesstoken().switchMap(refreshAccesstokenResponse => {
console.log(refreshAccesstokenResponse);
response.request.headers.set('Authorization', 'Bearer ' + refreshAccesstokenResponse);
//If you want to change request or make with it some actions and give the request to the repeatRequest func.
//Or you can live it empty and request will be the same.
return response.repeatRequest(response.request);
})
.subscribe(
res => responseHandler(res),
err => subject.error(err)
);
return false;
}
return true;
});
}),
...
And the screenshot of my browser.
So, I have a 403 error from my backend, but Rectangular say undefined 😢 .
Thanks for your help,
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
axios interceptors response undefined - Stack Overflow
I'm trying to logout my user once they get a 401. I'm using axios to return data ...
Read more >ngx-restangular - UNPKG
addErrorInterceptor ;\n\n /**\n * Response interceptor is called just before ... httpConfig] = undefined;\n\n return RestangularResource(this.config, $http, ...
Read more >Axios - Cannot read property 'status' of undefined - Laracasts
Hello , When I use axios to create a model I have this error message ? Uncaught (in promise) TypeError: Cannot read property...
Read more >Restangular Sample - Unsaved project - Plunker
_id = undefined; } return elem; }); }); // Controller for list route function ... addErrorInterceptor; /** * Response interceptor is called just...
Read more >Ts-lambda-api - npm.io
By default all return values are serialised to JSON in the response body and the ... Healthcheck / Status endpoint; Login Endpoint; Public...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Please update version ngx-restangular to 1.0.5. This may resolve your issue.
Yeah @logvinoleg89 , thanks!!! In case of 403 Forbidden answer, there is no hack to allow no JSON response?