question-mark
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.

Validate status not properly rejecting

See original GitHub issue

According to the documentation if validateStatus returns false then the promise is rejected. Well thats not the case for me, i’m only seeing the promise being resolved.

    let body = new URLSearchParams();

    body.append('grant_type', 'password');
    body.append('username', username);
    body.append('password', password);

    return axios
      .post('backend://oauth/token', body)
      .then((response) => {

        console.dir(response.config.validateStatus(response.response.status));

        this.writeToLocalStorage({
          ownerId: response.data.owner_id,
          accessToken: response.data.access_token,
          refreshToken: response.data.refresh_token,
          expiresIn: response.data.expires_in
        });

        return this
          .getById(this.oauthToken.ownerId)
          .then((user) => {
            this.currentUser = user;
            return user;
          });
      })
      .catch((error) => {
        if (error.response.status === 400) {
          throw new OAuthError(error.response.data);
        }

        throw new UnexpectedApiError(error.response);
      });

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
macnibbletcommented, Aug 24, 2016

@rubennorte Actually I found the cause of the issue it was related to an edge-case in a interceptor one of my minions added.

0reactions
hannes-dahlbergcommented, Jul 5, 2017

@macnibblet Found this issue when having the same problem as you and ended up with the same solution. An interceptor was causing the problem. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

REST: which HTTP Status for rejecting method on current ...
My reading is that "currently supported" implies that the list of supported methods may evolve over time. 403 Forbidden is also fine: The...
Read more >
Validation Error Messages Do Not Display on Approve or ...
Validation Error Messages Do Not Display on Approve or Reject Pages ... Navigate to any approval record in the "Assigned" status
Read more >
Error handling with promises
Let's improve error handling for the user-loading example. The promise returned by fetch rejects when it's impossible to make a request. For instance,...
Read more >
Rejections • Akka HTTP - Documentation
A rejection encapsulates a specific reason why a route was not able to handle a ... if the entity is not properly rejected...
Read more >
More on data validation - Microsoft Support
Users are not copying or filling data - Data validation is designed to show messages and prevent invalid entries only when users type...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found