You can use the following simple solution:
if ( this.subscription ) {
this.subscription.unsubscribe();
}
this.subscription = this.http.get( 'awesomeApi' )
.subscribe((res)=> {
// your awesome code..
})
More Related Contents:
- How can I chain HTTP calls in Angular 2?
- How to pass url arguments (query string) to a HTTP request on Angular?
- How to catch exception correctly from http.request()?
- What is httpinterceptor equivalent in angular2?
- Angular2 http.get() ,map(), subscribe() and observable pattern – basic understanding
- How to correctly set Http Request Header in Angular 2
- How to use angular2 http API for tracking upload/download progress
- Angular2 OPTIONS method sent when asking for http.GET [duplicate]
- Angular2 / Error: Collection not found
- Uses of content-disposition in an HTTP response header
- What’s the difference between a POST and a PUT HTTP REQUEST?
- How to detect server-side whether cookies are disabled
- ‘Refresh’ HTTP header
- Why is it common to put CSRF prevention tokens in cookies?
- Easy HTTP requests with gzip/deflate compression
- Wait for multiple promises to finish
- CORS request with Preflight and redirect: disallowed. Workarounds?
- How to redirect user’s browser URL to a different page in Nodejs?
- Why does my web server software disallow PUT and DELETE requests?
- What does “pending” mean for request in Chrome Developer Window?
- async/await in Angular `ngOnInit`
- Is a slash (“/”) equivalent to an encoded slash (“%2F”) in the path portion of an HTTP URL
- Save cookies between two curl requests
- Can I somehow do a synchronous HTTP request via NSURLSession in Swift
- How do I allow a PUT file request on Nginx server?
- Angular 4 HttpClient Query Parameters
- Chunked encoding and content-length header
- Is a URL with // in the path-section valid?
- Page transition animations with Angular 2.0 router and component interface promises
- How to set up CORS or OPTIONS for Rocket.rs