Service.ts
From this function I get like response a JSON like below:
public signupuser(user: Users): Observable<boolean> {
let headers = new Headers();
headers.append('Content-Type', 'application/json');
let body = user;
return this.http.post(Api.getUrl(Api.URLS.signup), body, {
})
.pipe(map((response: Response) => {
console.log('response', response)
return true;
}));
}
JSON:
response {
"email": "usertest@gmail.com",
"nome": "user",
"cognome": "test",
"abbonato": 0,
"cityid": "22",
"msg": "Registered correctly."
}
When I use it from Postman I get and status 200 OK or any status error
My question is: How to use this status from code, When this status code is not present in JSON file? Or any idea please?
Any idea please?
Update:
Looking at your code I believe you are using Angular, by default HttpClient observes the body not response. You will have to set the
observe
attribute in the options toresponse
then you should be able to read the status.