summaryrefslogtreecommitdiff
path: root/store
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2022-09-22 18:47:24 +0200
committerSanto Cariotti <santo@dcariotti.me>2022-09-22 18:47:24 +0200
commit598d5f22fcb91b14c6502403aabe1dcb0df39ce3 (patch)
treecb0ced4fe7c026ec69caab644ecccd78f138acd2 /store
parenta3844f2f839a040f1f2c0e7fe19414080e007e69 (diff)
Delete a model
Diffstat (limited to 'store')
-rw-r--r--store/models.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/store/models.js b/store/models.js
index 47f14b1..4f2297d 100644
--- a/store/models.js
+++ b/store/models.js
@@ -98,4 +98,29 @@ export const actions = {
return res;
},
+ // Delete a model
+ async deleteModel({ commit, rootGetters }, id) {
+ commit("loadingStatus", true, { root: true });
+ let res = { status: 0, data: null };
+ let api = this.$config.api;
+
+ await fetch(`${api}/v1/models/${id}`, {
+ method: "DELETE",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${rootGetters["auth/accessToken"]}`,
+ },
+ })
+ .then(async (response) => {
+ res.status = response.status;
+ res.data = await response.text();
+ })
+ .catch((e) => {
+ res.status = e.status;
+ });
+
+ commit("loadingStatus", false, { root: true });
+
+ return res;
+ },
};