Created
February 9, 2017 17:38
-
-
Save avatsaev/a6472d93859f8f1f7435fbec4e12071e to your computer and use it in GitHub Desktop.
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 } from '@angular/core'; | |
import {Angular2TokenService} from "angular2-token"; | |
import {environment} from "../environments/environment"; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.sass'] | |
}) | |
export class AppComponent { | |
title = 'app works!'; | |
constructor(private authToken: Angular2TokenService){ | |
this.authToken.init(environment.token_auth_config); | |
this.authToken.signIn({email: "user@example.com", password: "monkey67"}).subscribe( | |
res => { | |
console.log('auth response:', res); | |
console.log('auth response headers: ', res.headers.toJSON()); //log the response header to show the auth token | |
console.log('auth response body:', res.json()); //log the response body to show the user | |
}, | |
err => { | |
console.error('auth error:', err); | |
} | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment