I am making a PUT request to an endpoint in order to edit an entity, and if the PUT request fails, a response is returned that contains a validation message. Now I am a bit confused how to access that validation message considering the catch block of a try-catch only accepts an error.
Currently I have:
export const updateGame = async (game) => {
try {
await request.put('/game', { game });
} catch (error) {
console.log(error)
}
};
And if that PUT request fails, I get a response that looks like this:
{
error: {
message: 'Some error message'
}
}
However, I’m not quite sure how am I supposed to access that response considering the request fails and I only console log the error which does not contain that information