yunohost-admin/app/src/helpers/dataStore.js

29 lines
614 B
JavaScript
Raw Normal View History

import api from './api'
export default {
state: () => ({
2020-07-16 16:30:19 +02:00
domains: undefined,
users: undefined
}),
mutations: {
2020-07-16 16:30:19 +02:00
'SET_DOMAINS' (state, domains) {
state.domains = domains
},
'SET_USERS' (state, users) {
console.log(users)
state.users = Object.keys(users).length === 0 ? null : Object.values(users)
}
},
actions: {
async 'FETCH' ({ commit }, uri) {
2020-07-16 16:30:19 +02:00
return api.get(uri).then(responseData => {
const data = responseData[uri] ? responseData[uri] : responseData
commit('SET_' + uri.toUpperCase(), data)
})
}
},
getters: {
}
}