Can you tell me how can I consume a response from a post type request, in axios, which gives an error 422 (Unprocessable Entity)? I can't consume the JSON response from API, which would be, precisely, the error handling, with some information I need: example - { error: "ERROR_FROM_X_TO_Y" } (I'll need error attribute).
const postReq = () => {
return async () => {
try {
const url = '/exampleUrl/account-data';
try {
const response = await axios.post(url);
} catch (err) {
console.log(err);
}
} catch (error) {
console.log("error");
}
};
};
I already tried to console.log the response, but it doesn't works.