Reputation: 1560
In Http Module I can easily get the response code using response.status, but when I used HttpClient Module I cannot get the response.status, it shows undefined.
So, how can I get the response.status using HttpClient module in Angular 4. Please help.
Upvotes: 47
Views: 55732
Reputation: 2227
From this section, this is the adjusted code
http
.post<T>('/yoururl', whateverYourPostRequestIs, {observe: 'response'})
.subscribe(resp => {
console.log(resp);
});
the answer is {observe: 'response'}. you can then view the logged resp and pick/choose what you want.
Upvotes: 83