I am currently using axios to send form data to a Laravel backend.
While I can easily access the response upon success, I am facing difficulties retrieving the error response. In my browser's developer tools, under network > response, I see the following:
{"success":false,"data":{"message":"Token mismatch","refresh":true}}
My main goal is to retrieve the value of refresh in order to perform a boolean comparison. If it is true, I want to reload the page. How can I achieve this?
I have attempted the following techniques:
console.log(error.response);
console.log(error.response.data);
console.log(error.response.data.message);
console.log(error.data);
console.log(error);
These console logs displayed the following respectively:
[object Object]
[object Object]
undefined
undefined
Error: Request failed with status code 419