Guest User

Untitled

a guest
Mar 20th, 2018
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. onLogin () {
  2.  
  3. const formData = {
  4. email: this.email,
  5. password: this.password,
  6. returnSecureToken:true
  7. }
  8. this.$store.dispatch('login',{
  9. email: this.email,
  10. password: this.password,
  11.  
  12. }).then(res => {
  13. console.log("Role is",res);
  14. //this.$router.push('/'+role)
  15. this.$router.push('/dataEntry')
  16. });
  17. console.log("then here");
  18.  
  19. }
  20.  
  21. login({commit},authData){
  22. axios.post('http://localhost/laravel_back/public/api/login',authData
  23.  
  24. )
  25. .then(res => {
  26. console.log("Back-end Response",res);
  27.  
  28. commit('authUser',{
  29. token:res.data[0].token,
  30. userName:res.data[1][0].fname,
  31. id:res.data[2].id,
  32. type:res.data[3][0].role_id
  33.  
  34. })
  35. let role = res.data[3][0].role_id;
  36. console.log("Role inside action",role);
  37. resolve(role)
  38. })
  39.  
  40. .catch(error => console.log(error))
  41. console.log("FIRST ACTIONS");
  42.  
  43. }
Add Comment
Please, Sign In to add comment