Stack Overflow Asked by Goncalo Condeco on February 9, 2021
Im building a react app with a spring boot server and when i log in with password right, it comes 200 all works, but when i miss the password on purpose to test what happens, Axios does’t parse the error.
It says:
Error: Request failed with status code 403
at createError (createError.js:16)
at settle (settle.js:17)
at XMLHttpRequest.handleLoad (xhr.js:61)
and the actual error occurs here
export async function login(login: Credentials) {
try {
const result = await axios.put(base + 'user', login)
return result
} catch (err) {
--> console.log(err)
return err
}
}
The error occurs in the console.log, telling me it detected it was not a code 200 therefore it blew up there but it cant actually resolve the error?
Im quite lost with this, ive use axios for ages and this never happened.
I ve also deployed the server to Azure to not put the server and website in the same machine cuz cors but nothing helped.
Any thoughts?
Okay, I made a silly mistake. In the request function i do return err.response instead of THROW err.response Thats how it passes to be a rejected promise instead of fullfilled. Sorry.
Answered by Goncalo Condeco on February 9, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP