validateStatus doesn't work with auth
See original GitHub issueFollowing is my code
try {
const resToken = await axios({
method: 'post',
url: api.loginToken(),
validateStatus: function(status) {
return status < 500;
},
auth: {
username: option.username,
password: option.password
}
});
} catch (error) {
// some code here
}
Even though the validateStatus
is set to < 500
, the following exception is called:
POST http://localhost:8000/api/login/token 404 (Not Found)
Can you help me please? Is this a bug or am I doing something wrong?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:8 (2 by maintainers)
Top Results From Across the Web
How to handle 401 (Authentication Error) in axios and react?
The above solution is great but does not work well with multiple failed request, in turn it calls getToken with the updated token...
Read more >Understanding Axios GET requests - LogRocket Blog
Learn how to make GET requests in Axios with query parameters and API keys, plus concurrent and HEAD requests and error handling.
Read more >Axios HTTP error handling in Express.js
An authentication error 401 or 403 should not occur in our outgoing authentication since we always send a valid JWT.
Read more >Axios Cheat Sheet - Kapeli - Dash for macOS
`auth` indicates that HTTP Basic auth should be used, and supplies credentials. ... `validateStatus` defines whether to resolve or reject the promise for...
Read more >Splunk AppInspect API endpoint reference
To obtain an authentication token, send a GET request to the ... GET request to the /v1/app/validate/status/{request_id} endpoint on appinspect.splunk.com.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh sorry, I read your post too fast. It still seems to work with auth though.
I get an error logged to the console but my code never goes to the catch part because of the validateStatus
@Axnyff Yes, it works. You need to use
auth
option as you mentioned.