Last active
August 2, 2016 19:40
-
-
Save ThomasBurleson/5679256ea74e17cd4a6ff014478078a5 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 {Injectable} from 'angular2/core'; | |
import {Http, Headers} from 'angular2/http'; | |
import {SessionModel} from './global/session'; | |
@Injectable() | |
export class AuthenticatedHttpClient { | |
constructor(private http: Http, private session:SessionModel) { } | |
createAuthorizationHeader() { | |
return { | |
'x-auth-token' : this.session.sessionToken || localStorage.getItem('sessionToken') | |
}; | |
} | |
get(url) { | |
return this.http.get(url, { | |
headers: this.createAuthorizationHeader() | |
}); | |
} | |
post(url, data) { | |
return this.http.post(url, data, { | |
headers: this.createAuthorizationHeader() | |
}); | |
} | |
} |
Author
ThomasBurleson
commented
Aug 2, 2016
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment