summaryrefslogtreecommitdiff
path: root/store/users.js
diff options
context:
space:
mode:
Diffstat (limited to 'store/users.js')
-rw-r--r--store/users.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/store/users.js b/store/users.js
index cb9b4b4..e1f6767 100644
--- a/store/users.js
+++ b/store/users.js
@@ -61,4 +61,30 @@ export const actions = {
return res;
},
+ // Edit an user
+ async editUser({ commit, rootGetters }, payload) {
+ commit("loadingStatus", true, { root: true });
+ let res = { status: 0, data: null };
+ let api = this.$config.api;
+
+ await fetch(`${api}/v1/users/${payload.id}`, {
+ method: "PUT",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${rootGetters["auth/accessToken"]}`,
+ },
+ body: JSON.stringify(payload),
+ })
+ .then(async (response) => {
+ res.data = await response.json();
+ res.status = response.status;
+ })
+ .catch((e) => {
+ res.status = e.status;
+ });
+
+ commit("loadingStatus", false, { root: true });
+
+ return res;
+ },
};