Reputation: 19341
I implemented post method in angular 7. I want status code of post request.
I did following.
const sub = this.service.regEvent(this.pId, this.email)
.subscribe(response => {
console.log('response:', response);
if(response.httpStatusCode === 200) {
}
});
this.subscriptions.push(sub);
regEvent method
public regEvent(pId, email): Observable<any> {
return this.http.post<any>(`this.endpointUrl?eventId=${pId}&email=${email}`,"").pipe(
catchError(this.handleError)
);
}
Here console.log('response:', response);
I am getting null.
In browser i checked and it's.
In postman also.
any help would be greatly appreciated.
Upvotes: 0
Views: 749
Reputation: 10429
You will need to observe response something like
this.http.post<any>(`this.endpointUrl?eventId=${pId}&email=${email}`,"",{observe: 'response'})
Upvotes: 1