showrooms.js 948 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // import JSONAPI from 'vuejs/api/json-axios'
  2. import REST from 'vuejs/api/rest-axios'
  3. // import MA from 'vuejs/api/ma-axios'
  4. // import qs from 'querystring-es3'
  5. export default {
  6. namespaced: true,
  7. // initial state
  8. state: {
  9. items: [],
  10. showrooms_by_tid: {}
  11. },
  12. // getters
  13. getters: {},
  14. // mutations
  15. mutations: {
  16. setItems (state, items) {
  17. state.items = items
  18. items.forEach((item, i) => {
  19. state.showrooms_by_tid[item.tid] = item
  20. })
  21. // console.log('Showroom setitems', state.showrooms_by_tid)
  22. }
  23. },
  24. // actions
  25. actions: {
  26. getItems ({ dispatch, commit, state }) {
  27. REST.get('/showrooms_rest?_format=json', {})
  28. .then(({ data }) => {
  29. console.log('showrooms REST: data', data)
  30. commit('setItems', data)
  31. })
  32. .catch((error) => {
  33. console.warn('Issue with showrooms', error)
  34. Promise.reject(error)
  35. })
  36. }
  37. }
  38. }