Created
July 25, 2017 13:29
-
-
Save danielcrisp/2d34c0e71613362c8fa673dfb30bf6da to your computer and use it in GitHub Desktop.
AppComponent - Async HTTP Interceptors with Angular 4
This file contains 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 { Component, OnInit } from '@angular/core'; | |
import { HttpClient } from '@angular/common/http'; | |
@Component({ | |
selector: 'my-app', | |
template: '<div></div>' | |
}) | |
export class AppComponent implements OnInit { | |
constructor (private http: HttpClient) {} | |
ngOnInit () { | |
// immediately make a request | |
this.http.get('/user/me') | |
.subscribe(response => { | |
// ... do something with response | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment