reorg
This commit is contained in:
parent
c8d58db08a
commit
6af9d8619f
6 changed files with 4 additions and 4 deletions
36
frontend/src/services/frontendApi.js
Normal file
36
frontend/src/services/frontendApi.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
export const getRecipes = async () => {
|
||||
const response = await fetch("http://localhost:6063/recipes");
|
||||
const data = await response.json();
|
||||
return data;
|
||||
};
|
||||
|
||||
export const getRecipeById = async (id) => {
|
||||
const response = await fetch(`http://localhost:6063/recipe/${id}`);
|
||||
const data = await response.json();
|
||||
return data;
|
||||
};
|
||||
|
||||
export const addRecipe = async (recipeData) => {
|
||||
const response = await fetch("http://localhost:6063/add-recipe", {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(recipeData)
|
||||
});
|
||||
const data = await response.json();
|
||||
console.log(data)
|
||||
return data;
|
||||
};
|
||||
|
||||
export const deleteRecipe = async (id) => {
|
||||
console.log('run delete')
|
||||
console.log(id)
|
||||
// return
|
||||
const response = await fetch("http://localhost:6063/delete-recipe", {
|
||||
method: 'DELETE',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ id })
|
||||
});
|
||||
const data = await response.json();
|
||||
return data;
|
||||
};
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue