From 598d5f22fcb91b14c6502403aabe1dcb0df39ce3 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Thu, 22 Sep 2022 18:47:24 +0200 Subject: Delete a model --- store/models.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'store') diff --git a/store/models.js b/store/models.js index 47f14b1..4f2297d 100644 --- a/store/models.js +++ b/store/models.js @@ -96,6 +96,31 @@ export const actions = { commit("loadingStatus", false, { root: true }); + 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; }, }; -- cgit v1.2.3-18-g5258