Setting up Vuex for authentication
The first section of this chapter is all about creating another module in our Vuex state management, which will be for our app's auth module. This section will also help you learn how to add a new module to our Vuex store. This module will require new action types, new actions, a new state, and new mutations.
Before we start implementing this new module for our auth, we will need help from the the jsonwebtoken
npm
library. So, let's download the jsonwebtoken
library.
Run the following npm
command:
npm i jsonwebtoken
The preceding command will install the jsonwebtoken
package in our application.
Then, create a new folder in the src
directory and name it auth
.
Now, create a JavaScript file called auth.service.js
inside the auth
directory. Add the following code to the auth.service.js
file:
import api from "@/api/api-v1-config"; export async function loginUserAxios(login) { Â Â return await api.post("...