[Solved] Error: Request failed with status code 422 at createError (createError.js?2d83:16) at settle (settle.js?467f:17) at XMLHttpRequest.handleLoad (xhr.js?b50d:69)

2024/01/19 16:15

Error

Error: Request failed with status code 422
at createError (createError.js?2d83:16)
at settle (settle.js?467f:17)
at XMLHttpRequest.handleLoad (xhr.js?b50d:69)

 

This error occurs when axios returns the response body as an e.response object if an error occurs.
When an error occurs, the e.response object returns only the status code and message, and detailed error information such as messages cannot be obtained.

Solution

axios
.post(process.env.API_URL + ‘/api/v1/users/signup’)
.then((res) => {
console.log(res)
})
.catch((e) => {
console.log(e.response.data.messages)
})

Leave a Reply

Back to top