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

All http status code(40X, 50X) going to then function rather than catch #1968

Closed
gauravhanda25 opened this issue Jan 19, 2019 · 0 comments
Closed

Comments

@gauravhanda25
Copy link

gauravhanda25 commented Jan 19, 2019

Following code gives 400 error, but error not rejecting successfully to catch. It acts as error is resolved by promise.

axios.post("http://127.0.0.1:8000/api/login", {email: "rahul@xyz.com", languageId: 1, login_attempts: 1, password: "xxxxx"}).then(function (response) {
    // handle success
    console.log(response);
  })
  .catch(function (error) {
    // handle error
    console.log(error);
  })
  .then(function () {
  	console.log("response");
    // always executed
  });

Interceptor used

axios.interceptors.response.use(function (response) {
	if(response.headers.access_token) {
		setToken(response.headers.access_token);
	}
	return response;
}, function (error) {
	return Promise.reject(error);
});

How will I manage to catch http error in catch ???

@axios axios locked and limited conversation to collaborators May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant