UnhandledPromiseRejectionWarning: ValidationError: - PullRequest
0 голосов
/ 14 апреля 2020

Добрый день, я новичок, я прошел курс MEAN CRUD. Я запускаю сервер, и он идеален, но когда я использую POSTMAN и добавляю тело с новым сотрудником, заполняющим его соответствующие параметры, и при отправке запроса в POSTMAN появляется «загрузка», я вижу терминал, и все эти ошибки появляются, и он не показывает созданного сотрудника. Не могли бы вы помочь мне решить мою ошибку?

> server@1.0.0 dev /home/nahuel/Escritorio/CURSO ERROR/mean-employees-master
> nodemon ./server/index.js

[nodemon] 1.17.5
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node ./server/index.js`
server on port 3000
db is connected
(node:18699) UnhandledPromiseRejectionWarning: ValidationError: Employee validation failed: name: Path `name` is required., position: Path `position` is required., office: Path `office` is required., salary: Path `salary` is required.
    at new ValidationError (/home/nahuel/Escritorio/CURSO ERROR/mean-employees-master/node_modules/mongoose/lib/error/validation.js:27:11)
    at model.Document.invalidate (/home/nahuel/Escritorio/CURSO ERROR/mean-employees-master/node_modules/mongoose/lib/document.js:1832:32)
    at p.doValidate.skipSchemaValidators (/home/nahuel/Escritorio/CURSO ERROR/mean-employees-master/node_modules/mongoose/lib/document.js:1700:17)
    at /home/nahuel/Escritorio/CURSO ERROR/mean-employees-master/node_modules/mongoose/lib/schematype.js:808:9
    at process._tickCallback (internal/process/next_tick.js:61:11)
(node:18699) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:18699) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:18699) UnhandledPromiseRejectionWarning: ValidationError: Employee validation failed: name: Path `name` is required., position: Path `position` is required., office: Path `office` is required., salary: Path `salary` is required.
    at new ValidationError (/home/nahuel/Escritorio/CURSO ERROR/mean-employees-master/node_modules/mongoose/lib/error/validation.js:27:11)
    at model.Document.invalidate (/home/nahuel/Escritorio/CURSO ERROR/mean-employees-master/node_modules/mongoose/lib/document.js:1832:32)
    at p.doValidate.skipSchemaValidators (/home/nahuel/Escritorio/CURSO ERROR/mean-employees-master/node_modules/mongoose/lib/document.js:1700:17)
    at /home/nahuel/Escritorio/CURSO ERROR/mean-employees-master/node_modules/mongoose/lib/schematype.js:808:9
    at process._tickCallback (internal/process/next_tick.js:61:11)
(node:18699) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
(node:18699) UnhandledPromiseRejectionWarning: ValidationError: Employee validation failed: name: Path `name` is required., position: Path `position` is required., office: Path `office` is required., salary: Path `salary` is required.
    at new ValidationError (/home/nahuel/Escritorio/CURSO ERROR/mean-employees-master/node_modules/mongoose/lib/error/validation.js:27:11)
    at model.Document.invalidate (/home/nahuel/Escritorio/CURSO ERROR/mean-employees-master/node_modules/mongoose/lib/document.js:1832:32)
    at p.doValidate.skipSchemaValidators (/home/nahuel/Escritorio/CURSO ERROR/mean-employees-master/node_modules/mongoose/lib/document.js:1700:17)
    at /home/nahuel/Escritorio/CURSO ERROR/mean-employees-master/node_modules/mongoose/lib/schematype.js:808:9
    at process._tickCallback (internal/process/next_tick.js:61:11)
(node:18699) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 6)
...