1π
β
I think you are missing the .then on your axios requests. Here is some example:
const submitNewCategory = () => {
return new Promise((resolve) => {
axios.post('/api/categories/store', {
title: newCategory.value
}).then(response => {
resolve(response);
})
})
}
Using the .then you are waiting for the request to be completed.
βEditβ
You can also add a second function to your .then for errors
const submitNewCategory = () => {
return new Promise((resolve, reject) => {
axios.post('/api/categories/store', {
title: newCategory.value
}).then(response => {
resolve(response);
},
error => {
// Can add other treatments for errors
reject(error);
})
})
}
π€Alexandre Heinen
Source:stackexchange.com