mirror of
https://github.com/hay-kot/mealie.git
synced 2025-07-06 13:02:27 -07:00
parent
a899f46464
commit
8221c36a89
82 changed files with 895 additions and 937 deletions
|
@ -1,20 +1,23 @@
|
|||
const baseURL = "/api/";
|
||||
import axios from "axios";
|
||||
import utils from "@/utils";
|
||||
import store from "../store/store";
|
||||
|
||||
// look for data.snackbar in response
|
||||
function processResponse(response) {
|
||||
try {
|
||||
utils.notify.show(response.data.snackbar.text, response.data.snackbar.type);
|
||||
store.commit("setSnackBar", {
|
||||
text: response.data.snackbar.text,
|
||||
type: response.data.snackbar.type,
|
||||
});
|
||||
} catch (err) {
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const apiReq = {
|
||||
post: async function(url, data) {
|
||||
let response = await axios.post(url, data).catch(function(error) {
|
||||
post: async function (url, data) {
|
||||
let response = await axios.post(url, data).catch(function (error) {
|
||||
if (error.response) {
|
||||
processResponse(error.response);
|
||||
return error.response;
|
||||
|
@ -24,19 +27,8 @@ const apiReq = {
|
|||
return response;
|
||||
},
|
||||
|
||||
put: async function(url, data) {
|
||||
let response = await axios.put(url, data).catch(function(error) {
|
||||
if (error.response) {
|
||||
processResponse(error.response);
|
||||
return response;
|
||||
} else return;
|
||||
});
|
||||
processResponse(response);
|
||||
return response;
|
||||
},
|
||||
|
||||
get: async function(url, data) {
|
||||
let response = await axios.get(url, data).catch(function(error) {
|
||||
put: async function (url, data) {
|
||||
let response = await axios.put(url, data).catch(function (error) {
|
||||
if (error.response) {
|
||||
processResponse(error.response);
|
||||
return response;
|
||||
|
@ -46,8 +38,19 @@ const apiReq = {
|
|||
return response;
|
||||
},
|
||||
|
||||
delete: async function(url, data) {
|
||||
let response = await axios.delete(url, data).catch(function(error) {
|
||||
get: async function (url, data) {
|
||||
let response = await axios.get(url, data).catch(function (error) {
|
||||
if (error.response) {
|
||||
processResponse(error.response);
|
||||
return response;
|
||||
} else return;
|
||||
});
|
||||
// processResponse(response);
|
||||
return response;
|
||||
},
|
||||
|
||||
delete: async function (url, data) {
|
||||
let response = await axios.delete(url, data).catch(function (error) {
|
||||
if (error.response) {
|
||||
processResponse(error.response);
|
||||
return response;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue