title: cancel all pending requests angular4
body: <p>How can I cancel all pending promises in angular2. I know that promises are not cancellable, but is there some work around for this?How can I cancel all pending requests on logout.</p>
  
  <p>api-service</p>
  
  <pre><code>get(url: string) {
          let that = this;
          let getPromise = new Promise((resolve, reject) =&gt; {
              this
                  .httpService
                  .get(url)
                  // ...and calling .json() on the response to return data
                  .map((res: Response) =&gt; res.json())
                  .subscribe(response =&gt; {
                      resolve(response);
                  }, (error) =&gt; {
                      console.log(error);
                      reject(that.handleError(error));
                  }, () =&gt; {
                      console.log('API Subscription Complete!');
                  });
          });
          return getPromise;
      }
  </code></pre>
  
  <p>component-service</p>
  
  <pre><code>fetchData(url) {
          return new Promise(resolve =&gt; {
              this
                  .apiService
                  .get(url)
                  .then(response =&gt; {
                      resolve(response);
                  }).catch(error=&gt;{
                      console.log(error);
                  });
          });
      }
  </code></pre>