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.

Handling 401 Error

See original GitHub issue

i can’t handle the 401 Unauthorized error. but before that axios always console.log() the POST 401 (Unauthorized) error. i don’t want to see that. how to fix it.

alt tag

This is the error i got as result… i use Next.js / React

Error: Request failed with status code 401
    at createError (eval at evalScript (http://localhost:3000/_next/next-dev.bundle.js:36657:9), <anonymous>:971:16)
    at settle (eval at evalScript (http://localhost:3000/_next/next-dev.bundle.js:36657:9), <anonymous>:2964:13)
    at XMLHttpRequest.handleLoad (eval at evalScript (http://localhost:3000/_next/next-dev.bundle.js:36657:9), <anonymous>:813:8)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

14reactions
guastallaigorcommented, Jun 22, 2018

@Bilal112 Did you try catching the error with error.response.data.error? See example:

this.$http.$post('url', user).then((response) => {
  //
})
.catch((error) => {
  this.showErrors(error.response.data.error)
})

Btw, i’m using Nuxtjs and axios module.

10reactions
rubennortecommented, Jan 6, 2017

This is a regular HTTP response, not an issue in Axios.

You should check the documentation of the API you’re using in order to solve your problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

401 Unauthorized - HTTP - MDN Web Docs
The HyperText Transfer Protocol (HTTP) 401 Unauthorized response status code indicates that the client request has not been completed ...
Read more >
How to handle 401 (Authentication Error) in axios and react?
If you want to use interceptors to handle 401 error here is code snippet. axios.interceptors.response.use(response => { return response; } ...
Read more >
How to Fix a 401 Unauthorized Error? - GeeksforGeeks
The 401 Unauthorized Error is an HTTP status code error that represented the request sent by the client to the server that lacks...
Read more >
401 Error: 5 Ways to Troubleshoot and Fix It - Hostinger
The 401 Unauthorized error is triggered by unauthenticated requests made to a WordPress web server. Learn how to identify and fix the issue....
Read more >
A Useful Guide to Diagnosing and Solving the 401 Error
4 Different Methods to Solve the 401 Error · 1. Clean Up Your Browser Cookies and Cache Data · 2. Double-Check the Inserted...
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