import { REST } from 'api/rest-axios'

export default {
  namespaced: true,

  // initial state
  state: {
    projects: []
  },

  // getters
  getters: {},

  // mutations
  mutations: {
    setProjects (state, projects) {
      state.projects = projects
    }
  },

  // actions
  actions: {
    // async get authors
    getProjects ({ dispatch, commit, state }) {
      REST.get(`projects`, {})
        .then(({ data }) => {
          console.log('projects getProjects REST: data', data)
          commit('setProjects', data)
        })
        .catch((error) => {
          console.warn('Issue with getProjects', error)
          Promise.reject(error)
        })
    }
  }

}
