July 2018
Intermediate to advanced
420 pages
8h 46m
English
For the Logout function, we will use a different approach. Instead of using the map() operator, we will use the tap() operator.
Add the following code right after the onLogin() function:
onLogout(): Observable<User> {
return this.http.post(this.apiUrl + '/logout', httpOptions).pipe(
tap(
() => {
localStorage.removeItem('token');
this.router.navigate(['/']);
}
)
);
}
In the previous code, we just remove the token from localStorage and redirect the user to the home page. Now, it is time to create the local functions to deal with data.
Read now
Unlock full access