Add fruit to API
This commit is contained in:
@@ -15,6 +15,14 @@ export default {
|
||||
getFruit: async ({ commit }, id) => {
|
||||
await axios.get(`http://localhost:3000/fruit/${id}`).then(res => commit("setFruit", res.data));
|
||||
},
|
||||
addFruit: async ({ commit }, fruit) => {
|
||||
commit("setLoading", true);
|
||||
await axios
|
||||
.post("http://localhost:3000/fruit", fruit)
|
||||
.then(res => commit("addFruit", res.data))
|
||||
.catch(err => console.log(err))
|
||||
.finally(() => commit("setLoading", false));
|
||||
},
|
||||
removeFruit: async ({ commit }, id) => {
|
||||
await axios
|
||||
.delete(`http://localhost:3000/fruit/${id}`)
|
||||
|
||||
Reference in New Issue
Block a user