Skip to content
Advertisement

Im getting an error in my react and rest api app where one of my variables is coming back undefined

thank you for your time if youre reading this, im making a full stack app with react and rest api and im encountering an error as such:

JavaScript

the part where this error is throwing is right here:

JavaScript

heres my createUser function code:

JavaScript

heres the code handiling post / users

JavaScript

Im really not sure whats going on with my errors variable here so if anyone could help me that would be great heres my github link: https://github.com/zakMossy/react-and-rest-api-project-10

Advertisement

Answer

Your createUser function code returns data.errors if the response status is not 201. But your API sends the errors in the error key. Update the key to errors in your API route handler and you should be good to go.

JavaScript
Advertisement