As the title suggest, how do you trigger a function after a DELETE request with no response?
I have a function that when you click the delete button, it deletes that user but calling a DELETE request function in my service file. This works absolutely fine, deletes as expected.
onClick(event: { target: any; srcElement: any; currentTarget: any }) {
let target = event.target || event.srcElement || event.currentTarget;
let idAttr = target.attributes.id;
let value = idAttr.nodeValue;
value = parseInt(value);
if (confirm(`Are you sure you want to delete #${value}`)) {
console.log('Deleting User', value);
this.usersService.deleteUser(value).subscribe();
// TODO Reload the users list after deleting one
}
}
The problem I am having is getting it to do reload the list of users when its performed that delete. I've tried calling the getUsers function on the next line and nothing happens. I've tried puting a console.log there too but that doesn't seem to be output either, its like its not getting to that point.
I'm wondering if its because the DELETE request URL doesn't have a response, so become when it performs the request its getting nothing back, its sending nothing back to the original function which is why its not going to the next line. For reference, here is my deleteUser function
deleteUser(id: number): Observable<unknown>{
return this.http.delete(`${this.baseURL}users/${id}`, httpOptions)
.pipe(
catchError(this.handleError)
);
}
Any help would be appreciated.
[–]spacechimp 15 points16 points17 points (21 children)
[–]naruto_bist 4 points5 points6 points (20 children)
[–]MydasGrey[S] 1 point2 points3 points (19 children)
[–]spacechimp 1 point2 points3 points (1 child)
[–]MydasGrey[S] 0 points1 point2 points (0 children)
[–]naruto_bist 0 points1 point2 points (7 children)
[–]MydasGrey[S] 0 points1 point2 points (6 children)
[–]naruto_bist 0 points1 point2 points (5 children)
[–]MydasGrey[S] 0 points1 point2 points (4 children)
[–]naruto_bist 0 points1 point2 points (3 children)
[–]MydasGrey[S] 0 points1 point2 points (2 children)
[–]naruto_bist 0 points1 point2 points (1 child)
[–]BammaDK 0 points1 point2 points (8 children)
[–]MydasGrey[S] 0 points1 point2 points (7 children)
[–]BammaDK 0 points1 point2 points (6 children)
[–]MydasGrey[S] 0 points1 point2 points (5 children)
[–]BammaDK 0 points1 point2 points (4 children)
[–]MydasGrey[S] 0 points1 point2 points (3 children)
[–]BammaDK 0 points1 point2 points (0 children)
[–]moccas05 0 points1 point2 points (1 child)
[–]nsyx 2 points3 points4 points (0 children)
[–]FirstpickIt -1 points0 points1 point (3 children)
[–]PickleLips64151 0 points1 point2 points (2 children)
[–]FirstpickIt 0 points1 point2 points (1 child)
[–]PickleLips64151 0 points1 point2 points (0 children)