showrooms.js 905 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 = state.items.concat(items)
  18. items.forEach((item, i) => {
  19. state.showrooms_by_tid[item.tid] = item
  20. })
  21. }
  22. },
  23. // actions
  24. actions: {
  25. getItems ({ dispatch, commit, state }) {
  26. REST.get('/showrooms_rest?_format=json', {})
  27. .then(({ data }) => {
  28. console.log('showrooms REST: data', data)
  29. commit('setItems', data)
  30. })
  31. .catch((error) => {
  32. console.warn('Issue with showrooms', error)
  33. Promise.reject(error)
  34. })
  35. }
  36. }
  37. }