I am currently working on a project using Angular 7 and I have the following code snippet:
public deleteId(pId){
return this.http.delete<any>(this.deleteUrl(pId), {observe: 'response'})
.pipe(catchError(this.handleError));
}
In my delete method, I need a 202 response status. However, I am only getting a 200 response status.
public deleteMethod(): void {
this.service.deleteId(this.id)
.subscribe(response => {
console.log(`Delete response ` , response);
if(response.status === 200) {
console.log('Deleted successfully');
}
else if(response.status === 202) {
console.log('something else'); // I am not getting response.status here
}
});
}
Currently, when I encounter a 202 status code, it is redirected to the handleError method instead of being treated as a response. How can I resolve this issue?
private handleError(error: HttpErrorResponse) {
//It sends me to this function.
}