Add Database Layer for Recipe Scaling (#506)

* move badge

* fix add individual ingredient

* fix redirect issue

Co-authored-by: hay-kot <hay-kot@pm.me>
This commit is contained in:
Hayden
2021-06-12 22:23:23 -08:00
committed by GitHub
parent 0a927afaa0
commit e95ca870b1
18 changed files with 298 additions and 62 deletions

View File

@@ -31,6 +31,7 @@ const apiReq = {
post: async function(url, data, getErrorText = defaultErrorText, getSuccessText) {
const response = await axios.post(url, data).catch(function(error) {
handleError(error, getErrorText);
return error;
});
return handleResponse(response, getSuccessText);
},
@@ -38,6 +39,7 @@ const apiReq = {
put: async function(url, data, getErrorText = defaultErrorText, getSuccessText) {
const response = await axios.put(url, data).catch(function(error) {
handleError(error, getErrorText);
return error;
});
return handleResponse(response, getSuccessText);
},
@@ -45,6 +47,7 @@ const apiReq = {
patch: async function(url, data, getErrorText = defaultErrorText, getSuccessText) {
const response = await axios.patch(url, data).catch(function(error) {
handleError(error, getErrorText);
return error;
});
return handleResponse(response, getSuccessText);
},
@@ -52,12 +55,14 @@ const apiReq = {
get: async function(url, data, getErrorText = defaultErrorText) {
return axios.get(url, data).catch(function(error) {
handleError(error, getErrorText);
return error;
});
},
delete: async function(url, data, getErrorText = defaultErrorText, getSuccessText = defaultSuccessText) {
const response = await axios.delete(url, data).catch(function(error) {
handleError(error, getErrorText);
return error;
});
return handleResponse(response, getSuccessText);
},

View File

@@ -35,9 +35,11 @@ export const recipeAPI = {
},
async requestDetails(recipeSlug) {
let response = await apiReq.get(API_ROUTES.recipesRecipeSlug(recipeSlug));
if (response && response.data) return response.data;
else return null;
const response = await apiReq.get(API_ROUTES.recipesRecipeSlug(recipeSlug));
if (response.response) {
return response.response;
}
return response;
},
updateImage(recipeSlug, fileObject, overrideSuccessMsg = false) {