422 Not returning send message(Node.js/Redux)

Home / Uncategorized / 422 Not returning send message(Node.js/Redux)

Question:
I am having an issue where my node.js server is returning a 422 to the browser with a message but the browser is just seeing the 422 and nothing with it.
//Node.js
if (existingUser) {
return res.status(422).send({ error: ‘Email is in use’ });
}

I can confirm it is hitting there and returning at that point
//Redux method
export function signupUser({ email, password }) {
return function(dispatch) {
return axios.post(`${ROOT_URL}/signup`, { email, password })
.then(response => {
dispatch(emailWasSent(response.data.return_msg));
})
.catch(response => {
dispatch(authError(response.data.error));});
}
}

It will hit the catch but the response only contains 422
//Console.log of response
Error: Request failed with status code 422


Answer:

Read more

Leave a Reply

Your email address will not be published. Required fields are marked *