У меня небольшая проблема с моим запросом в NodeJ. Я хочу проанализировать мой JSON, но я хочу показать msg.errors.email.message , который содержит сообщение об ошибкемоя оценка.
Мои ошибки:
throw er; // Unhandled 'error' event
^
TypeError: Cannot read property 'errors' of undefined
Код узлаjs:
if (err) {
return res.status(500).json({ msg: err.msg.errors.email.message });
}
Retour JSON *
{
"msg": {
"errors": {
"email": {
"message": "Is not a valid e-mail.",
"name": "ValidatorError",
"properties": {
"message": "Is not a valid e-mail.",
"type": "user defined",
"path": "email",
"value": "f@f"
},
"kind": "user defined",
"path": "email",
"value": "f@f",
"$isValidatorError": true
},
"password": {
"message": "Password needs to have at least one lower case, one uppercase, one number, one special character, and must be at least 8 characters but no more than 35.",
"name": "ValidatorError",
"properties": {
"message": "Password needs to have at least one lower case, one uppercase, one number, one special character, and must be at least 8 characters but no more than 35.",
"type": "user defined",
"path": "password",
"value": "dede-DSQds"
},
"kind": "user defined",
"path": "password",
"value": "dede-DSQds",
"$isValidatorError": true
}
},
"_message": "users validation failed",
"message": "users validation failed: email: Is not a valid e-mail., password: Password needs to have at least one lower case, one uppercase, one number, one special character, and must be at least 8 characters but no more than 35.",
"name": "ValidationError"
}
}
Я хочу показать
msg.errors.email.message