user.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { HTTP } from 'vuejs/rest/http-axios'
  2. export default {
  3. namespaced: true,
  4. // initial state
  5. state : {
  6. isloggedin: false,
  7. username: '',
  8. token: null
  9. },
  10. // getters
  11. getters : {},
  12. // mutations
  13. mutations : {
  14. // setUser (state, posts) {
  15. // state.all = posts
  16. // }
  17. // setOpened (state, post) {
  18. // state.opened = post
  19. // },
  20. // clearOpened (state) {
  21. // state.opened = null
  22. // }
  23. },
  24. // actions
  25. actions : {
  26. getToken ({ commit, state }, data) {
  27. // console.log('getToken data', data)
  28. let config = {
  29. headers: {
  30. "Content-Type": "application/json"
  31. }
  32. }
  33. // console.log('data', data)
  34. // console.log('config', config)
  35. HTTP.post('/user/login?_format=json', data, config)
  36. .then(response => {
  37. console.log('response', response)
  38. // cb(response.data)
  39. })
  40. .catch(({ error }) => {
  41. console.log('Issue with login', error);
  42. Promise.reject(error);
  43. })
  44. }
  45. // ,
  46. // logout ({ commit }) {
  47. //
  48. // }
  49. }
  50. }