Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. // This is the action from my "auth store"
  2. login: ({commit}, userData) => {
  3. commit('auth_request')
  4. Api.post('login', userData)
  5. .then(res => {
  6. const token = res.data.data.token
  7. localStorage.setItem('token', token)
  8. Api.defaults.headers.common['Authorization'] = "Bearer " + token
  9. commit('auth_success', token)
  10. })
  11. .catch(err => {
  12. commit('auth_error')
  13. console.log("Failed to login, check your username or password")
  14. })
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement