feat(recipe): añadida función para editar recetas en services y stores

parent f7d7eede
import RecipeDetail from '@/views/RecipeDetail.vue';
import api from './api';
export const recipeService = {
......@@ -29,5 +30,9 @@ export const recipeService = {
delete: async (id) => {
const response = await api.delete(`/recipe/${id}`);
return response.data;
},
update: async (recipeId, newData) => {
const response = await api.put(`/recipe/${recipeId}`, newData);
return response.data;
}
}
\ No newline at end of file
......@@ -70,6 +70,15 @@ export const useRecipeStore = defineStore('recipe', {
console.error('Error al eliminar la receta', error);
throw error;
}
},
async update(recipeId, newData) {
try {
const updatedRecipe = await recipeService.update(recipeId, newData);
this.recipe = updatedRecipe;
} catch (error) {
console.error('Error al editar la receta', error);
throw error;
}
}
}
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment