Skip to content Skip to sidebar Skip to footer

Send Post Request In Angular 6 Without Wait To Response

I want to send a http post request from an angular 6 app when I close my app. My problem is when I close the app, the http request gets aborted. How can I send a http post request

Solution 1:

But is doesn't work because the page is closing and it doesn't get to the subscribe and in the network it said that the request was canceled

Solution 2:

I would subscribe, because if not it won't fire. Then do nothing with the response.

this.http.post( url, body, headers ).subscribe(
   data => {
            // don't do nothing
           }
   );

Solution 3:

Then (assuming you're using the HttpClient), you will just call the method without the subscription logic like that:

this.http.post(URL,BODY).subscribe();

Post a Comment for "Send Post Request In Angular 6 Without Wait To Response"