Skip to content

Instantly share code, notes, and snippets.

@nanotroy
Created June 28, 2019 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nanotroy/1f01024432f3d113b50aa290443e86bc to your computer and use it in GitHub Desktop.
Save nanotroy/1f01024432f3d113b50aa290443e86bc to your computer and use it in GitHub Desktop.
token = this.auth.getToken() // auth is provided via constructor.
if (token) {
// Logged in. Add Bearer token.
return next.handle(
req.clone({
headers: req.headers.append('Authorization', 'Bearer ' + token)
})
);
}
// Not logged in. Continue without modification.
return next.handle(req);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment