0

I'd like to be able to handle the 401 status code in my angularjs project. I've attempted several different variations of response interceptors, but all of them return a code of -1. I'd like to understand why this is happening. Using Angularjs v1.5.8.

myApp.factory('httpResponseInterceptor', function () {
  return {
    responseError: function (config) {
      console.log(config.status);
      //The above prints out -1 to the console
      return config;
    }
  };
});

myApp.config(function ($httpProvider) {
  $httpProvider.interceptors.push('httpResponseInterceptor');
});

1 Answer 1

1

It is CORS issue, CORS is Cross-Origin Resource Sharing. You must enable CORS from server side.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.