Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This is the action from my "auth store"
- login: ({commit}, userData) => {
- commit('auth_request')
- Api.post('login', userData)
- .then(res => {
- const token = res.data.data.token
- localStorage.setItem('token', token)
- Api.defaults.headers.common['Authorization'] = "Bearer " + token
- commit('auth_success', token)
- })
- .catch(err => {
- commit('auth_error')
- console.log("Failed to login, check your username or password")
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement