summaryrefslogtreecommitdiff
path: root/store/models.js
diff options
context:
space:
mode:
Diffstat (limited to 'store/models.js')
-rw-r--r--store/models.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/store/models.js b/store/models.js
index 4f2297d..44dbb56 100644
--- a/store/models.js
+++ b/store/models.js
@@ -123,4 +123,30 @@ export const actions = {
return res;
},
+ // Edit a model
+ async editModel({ commit, rootGetters }, payload) {
+ commit("loadingStatus", true, { root: true });
+ let res = { status: 0, data: null };
+ let api = this.$config.api;
+
+ await fetch(`${api}/v1/models/${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;
+ },
};