show actual error in result message mongoose node validation
The problem was the way i was calling the error in the front end. it needs to be error.response incase anyone runs into this problem
FUNCTION CALLING AXIOS IN FRONT END
API.createUser({ userEmail: this.state.profile.email.toLowerCase(), }) .then(function (response) { console.log(response); }) .catch(function (error) { if(error.response.data.code == 11000){ console.log("THE EMAIL IS ALREADY IN THE DATABASE"); } console.log(error.response); })
AXIOS FUNCTION IN API file
createUser: function(userData){ return axios.post("/api/wmUser/", userData); }