I´m trying to authenticate using axios, but when is error 400 or 401, in the cases of missing or wrong email and password I can't get the response message from the API, console logging axios error only shows me this:
error => Error: Request failed with status code 400 at createError (1.chunk.js:104463) at settle (1.chunk.js:104697) at XMLHttpRequest.handleLoad (1.chunk.js:103940)
Dont know how to get the proper response, which is this: {"errors":[{"message":"Please supply e-mail and password."}]}
Here is my code
(...)
axios.post('some api for authentication',
{
email: formData.email,
password: formData.password,
remember: formData.remember
})
.then(response => {
token = response.data.session.user
console.log('response =>', token)
})
.catch((error) => {
token = null
console.log('error =>', error)
})
(...)
Thanks
{"errors":[{"message":"Please supply e-mail and password."}]}
. What types iserrors
? Which element of that type has the error? Which property on that element has the error message string? Is the issue accessing/finding an element in an array? – Alexander Staroselskyconsole.log(error.response.data);
in thecatch
. – Alexander Staroselsky