July 2018
Intermediate to advanced
420 pages
8h 46m
English
We are almost at the end of our authentication service, but we still need to create some helper functions that we will use in other application blocks.
Let's create the functions to handle the user token. Recreating call from our backend with Laravel that we are using the jwt-auth library to authenticate our users.
In this example, we are using localStorage to store the user's token. So, let's create two very simple functions to write and retrieve this token.
Right after the logout() function, add the following block of code:
setToken(token: string): void {
return localStorage.setItem('token', token );
}
getToken(): string {
return localStorage.getItem('token');
}
Read now
Unlock full access