Dániel Kis Dániel Kis - 1 year ago 217
TypeScript Question

Cancel http request

In jQuery ajax there's a way to abort ajax queries:

var xhr = $.ajax({ ... });

when user wants to abort the operation or navigates to other page in a single page app I can call


In angular2-http api I cannot find any possibility to abort the query as it uses rxjs.

Is there a way to abort the ajax query in angular2?

Answer Source

When you subscribe, you get a subscription you can use to unsubscribe

this.httpSubscription = this.http.get(...).subscribe(...);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download