Skip to content

Instantly share code, notes, and snippets.

@cp-sumi-k
Last active June 27, 2022 04:22
Show Gist options
  • Save cp-sumi-k/fd5c969d0cc0380a0ecc3b7b7037e4d3 to your computer and use it in GitHub Desktop.
Save cp-sumi-k/fd5c969d0cc0380a0ecc3b7b7037e4d3 to your computer and use it in GitHub Desktop.
/*
vuex store actions
*/
const actions = {
getJobs({ commit }) {
return new Promise((resolve, reject) => {
axios
.get(BASE_API_URL + "/api/careers")
.then((response) => {
commit("SET_JOBS", response.data);
resolve(response);
})
.catch((error) => {
commit("SET_JOBS_ERROR", error);
reject(error);
});
});
},
}
/*
pinia store actions
*/
const actions = {
getJobs() {
return new Promise((resolve) => {
axios
.get(BASE_API_URL + "/api/careers")
.then((response) => {
//removed mutation and update store directly using this
this.items = response.data;
resolve();
})
.catch((error) => {
//removed mutation and update store directly using this
this.error = error;
resolve();
});
});
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment