Skip to content

Instantly share code, notes, and snippets.

@danielcrisp
Created July 25, 2017 13:29
Show Gist options
  • Save danielcrisp/2d34c0e71613362c8fa673dfb30bf6da to your computer and use it in GitHub Desktop.
Save danielcrisp/2d34c0e71613362c8fa673dfb30bf6da to your computer and use it in GitHub Desktop.
AppComponent - Async HTTP Interceptors with Angular 4
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