diff options
author | Santo Cariotti <santo@dcariotti.me> | 2022-09-25 16:16:31 +0200 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2022-09-25 16:16:31 +0200 |
commit | 179c470ff9c91f8206b9e0d53d5b6563656e28b1 (patch) | |
tree | 8a766eee58447ce13b5dc222460841e7e41fb459 /store | |
parent | 6481d712dbe58b5996a33567fe314f8a513023fa (diff) |
Edit user
Diffstat (limited to 'store')
-rw-r--r-- | store/users.js | 26 |
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; + }, }; |