Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AddErrorInterceptor: response.status is undefined

See original GitHub issue


Same problem as #44. Here my code:

        RestangularModule.forRoot([Http], (RestangularProvider, http) => {
            // 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');

            RestangularProvider.addErrorInterceptor((response, subject, responseHandler) => {
                console.log(Object.keys(response), response.status, response);

                if (response.status === 403) {
                    refreshAccesstoken().switchMap(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);
                        res => responseHandler(res),
                        err => subject.error(err)
                    return false;

                return true;

And the screenshot of my browser. screen shot 2017-04-11 at 22 59 36

So, I have a 403 error from my backend, but Rectangular say undefined 😢 .

Thanks for your help,

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

logvinoleg89commented, Apr 17, 2017

Please update version ngx-restangular to 1.0.5. This may resolve your issue.

DarkIsDudecommented, Apr 17, 2017

Yeah @logvinoleg89 , thanks!!! In case of 403 Forbidden answer, there is no hack to allow no JSON response?

Read more comments on GitHub >

github_iconTop 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 -
By default all return values are serialised to JSON in the response body and the ... Healthcheck / Status endpoint; Login Endpoint; Public...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found