How to get the status code of all the request using HttpClient
apiCall() {
let header1 = new HttpHeaders();
header1 = header1.append('Content-Type', 'application/json');
header1 = header1.append('Authorization', `Bearer ${this.token}`);
this.http.post("URL",
{
"dataSentHere": "data"
}, {
headers: header1
}).subscribe(data => {
console.log(data);
},
(err: HttpErrorResponse) => {
if (err.status === 403) {
console.log("403 status code caught");
}
}
)
}
How to get the status code of the http request which returns 202 , 200 etc.