axios.post("/api/end", {data : "xx"})
.then(({ data }) => {
// doing something with success
})
.catch((err) => {
let message = typeof err.response !== "undefined" ? err.response.data.message : err.message;
console.warn("error", message);
});
axios.post('/formulas/create', {
name: "",
parts: ""
})
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error.response)
});
.catch(function (error) {
if (error.response) {
console.log(error.response.data);
console.log(error.response.status);
console.log(error.response.headers);
}
axios.get('/api/xyz/abcd')
.catch(function (error) {
if (error.response) {
// Request made and server responded
console.log(error.response.data);
console.log(error.response.status);
console.log(error.response.headers);
} else if (error.request) {
// The request was made but no response was received
console.log(error.request);
} else {
// Something happened in setting up the request that triggered an Error
console.log('Error', error.message);
}
});
axios.post('/formulas/create', {
name: "",
parts: ""
})
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error.response)
});
.catch((error) => {
const errorMessage = error?.response?.data?.message;
const message = errorMessage || "your custome message";
this.$toast.show(message, {
icon: "info",
className: "toast-danger",
});
})
axios.get(...).catch( error => { return Promise.reject(error.response.data.error); });