I use React + Django, when user signup from frontend the axios in React send POST signal to Django, if form is invalid it shows below response
xhr.js:178 POST http://localhost:8000/account/users/
signup.js:120 Error: Request failed with status code 400
at createError (createError.js:16)
at settle (settle.js:17)
at XMLHttpRequest.handleLoad (xhr.js:61)
If I do same POST with invalid fields in Django browsable API or Postman I get below error and it is useful to display error to users
{
"email": [
"This field may not be blank."
],
"username": [
"This field may not be blank."
]
}
If user type invalid details in form and after form submission, How can I get same error message from axios ?
Please note that if user type correct information in form, axios responds with sufficient details.
Axios function
axios.post('/account/users/',{data}).then(res=>console.log(res)).catch(err=>console.log(err)