1

I have a problem with axios. Even when request returns with 200 promise is always rejected.

let params = new URLSearchParams(); params.append('email', credentials.email); params.append('password', credentials.password); params.append('grant_type', 'email'); params.append('scope', 'read write'); let promise = axios.post('/backend/oauth/token', params, { headers: { 'Accept': 'application/json' } }).then((response) => { console.log(response); let loginData = response.data; let expiredAt; expiredAt = new Date; expiredAt.setSeconds(expiredAt.getSeconds() + loginData.expires_in); loginData.expires_at = expiredAt.getTime(); store.set('token', loginData); }, (err) => { console.log("LOL"); console.log(err); }); 

error function is always called, and err object has status: '200', statusText: 'ok'. Am i doing something wrong?

1
  • I thought it was the new Date instead of new Date()... remember if you do any error in the success handler (then) it also jumps out to the catch handler... but then maybe this was just a typo Commented May 2, 2018 at 14:20

1 Answer 1

1

It was my error, in one of my response interceptors that I forgot about I was rejecting the promise.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.