HttpErrorResponse status returns 0 instead of 401
See original GitHub issueI’m trying to build an interceptor to handle 401 requests, but even in the subscribe error function handler the status is 0. I tried setting observe: response but that didn’t help.
this.http .get<ILead>(this.leadApiUrl) .subscribe( data => { console.log('data' + data); this.company = data; }, err => { console.log(err); })
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (2 by maintainers)
Top Results From Across the Web
Getting status zero instead of 401 in the response
BTW, I'm using Angular 4.0.0 (core and http). This is the error I'm getting in the console due to the post request sent...
Read more >Angular — How to intercept 401 err response and redirect to ...
Below is an example of listening to an http response which was sent by the app to the api and returned with status...
Read more >HttpErrorResponse - Angular
A response that represents an error or failure, either from a non-successful HTTP status, an error while executing the request, or some other...
Read more >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 >401 Unauthorized Error: What It Is and How to Fix It
We'll show you how to diagnose and debug this error within your own application. Server- or Client-Side? All HTTP response status codes in...
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 Free
Top 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
HI… after a loooooong time on it…i found the issue… its of course in server side. you need to set the CORS middle ware first then the remaining API middlewares
Wrong Code
Currect Code
I want to know why Chrome and FireFox can show 401 on console while Angular caught 0. Are these browsers changed 401 to 0 before browser API passed the result to js . @danwulff