Skip to content

Instantly share code, notes, and snippets.

@dasmido
Last active January 20, 2018 21:41
Show Gist options
  • Save dasmido/7f8e93add0e2ae6453d5bb0dbb82ffbc to your computer and use it in GitHub Desktop.
Save dasmido/7f8e93add0e2ae6453d5bb0dbb82ffbc to your computer and use it in GitHub Desktop.
// function for authenticate user
// function to get profile
getProfile(){
let headers = new Headers();
this.loadToken();
headers.append('Authorization', this.authToken);
headers.append('Content-Type', 'application/json');
return this.http.get('http://localhost:9090/users/profile', {headers: headers}).map(res => res.json());
}
// fetch token from local Storage
loadToken(){
const token = localStorage.getItem('id_token');
this.authToken = token;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment