Http.get don't shows error 401

I need to check if I got an error 401.

For example, this request should cause an error:

let headers = new Headers({ 'Content-Type': 'application/json',  'Authorization': token + 'THIS  SHOULD CAUSE AN 401 ERROR ' });      
let url = thisObj.amazonUrl + func + argsStr;   
let options = new RequestOptions ({ headers: headers});                                 

thisObj.http.get(url,  options)
                                function(response: any) {
                                    body = JSON.parse(response);
                                    cb(null, body);
                                function(error) {                                
                                    console.error('GET: error);

But this error response don’t carry any information on error type.

How could I retrieve information o error type?

Can you share exactly what is being returned by the error method?

Additionally, TypeScript is starting to move away from callbacks, and into promises so I recommend you look into that as well.

Finally, for performance reasons, you should always unsubscribe from observables when you are done with them.

I got this response:

I will try to replace it with a promise. In fact I already used a promise in this part of the code and don’t got the correct error code.

Sounds like something is wrong with your backend. I really can’t diagnose the issue with such little information.

The backend seems OK since I got the 401 code in the header of the response while testing with PostMan.