0👍
Steps:-
-
Import the auth module from @nuxtjs/auth
-
Create a function called logout that uses the auth.logout() method.
-
Bind the logout function to an event, such as a button click.
-
When the event is triggered, the logout function will be called and the user will be logged out.
Nuxt3/Vue JS Simple Example:-
JS part
import { auth } from '@nuxtjs/auth';
export default {
methods: {
logout() {
await auth.logout(); // clear the user's token from local storage and redirect the user to the login page
},
},
};
HTML part
<button @click="logout">Logout</button>
- [Vuejs]-Add custom error page for static directory in nuxt 2
- [Vuejs]-Running .vue files with Syntax Highlighting in IntelliJ IDEA Community Edition
Source:stackexchange.com