Created
November 8, 2016 22:23
-
-
Save joshwiens/9352109b16a01574f8f0e698fab20d1d to your computer and use it in GitHub Desktop.
Basic HTTP Interception
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { | |
Http, | |
RequestOptions, | |
RequestOptionsArgs, | |
Response, | |
ConnectionBackend | |
} from '@angular/http'; | |
import { Observable } from 'rxjs/Observable'; | |
@Injectable() | |
export class InterceptHttpService extends Http { | |
public constructor(_backend: ConnectionBackend, _defaultOptions: RequestOptions) { | |
super(_backend, _defaultOptions); | |
} | |
public get(url: string, options?: RequestOptionsArgs): Observable<Response> { | |
let response = super.get(url, options); | |
response.subscribe(null, error => { | |
// Execute the codez here :) | |
}); | |
return response; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment