Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception in interceptor if the response doesn't have data set #82

Open
shoaibmerchant opened this issue Mar 21, 2015 · 2 comments
Open

Comments

@shoaibmerchant
Copy link

I am using the $http interceptor to log all server messages on growl. In one random tests, we had CORS disabled on the server so there was no response sent all which resulted in growl throwing an exception.

I traced it to this line 160 in growlFactory.js

 this.serverMessagesInterceptor = ['$q', 'growl', function ($q, growl) {
    function checkResponse (response) {
      if (response !== undefined && response.data[_messagesKey] && response.data[_messagesKey].length > 0) {
        growl.addServerMessages(response.data[_messagesKey]);
      }
    }

    return {
      'response': function (response) {
        checkResponse(response);
        return response;
      },
      'responseError': function (rejection) {
        checkResponse(rejection);
        return $q.reject(rejection);
      }
    };
  }];

In the if conditions if you add another condition to check response.data not null, it can solve this.

      if (response !== undefined && response.data !== null && response.data[_messagesKey] && response.data[_messagesKey].length > 0) {

I know this is a special case (CORS disabled) but it would be nice to have the plugin addressing all possible scenarios. Looking forward for an update on this.

Thanks for all your work done on growl-v2!

@althaus
Copy link

althaus commented May 31, 2016

I'm getting the same issue with aborting pending requests on page exit.

@flaviocysne
Copy link

There was an update in 30 Apr 2015 that has added those checks.

Please, see if it's resolved and, if it is, close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants