You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please who can advise or check what went wrong here, or any solutions. I have checked countless times and compared my code with the one of the instructor, i couldn't find any error.
PLEASE HELP !!
Database Connection is ready...
(node:6064) UnhandledPromiseRejectionWarning: ValidationError: Product validation failed: price: Cast
to Number failed for value "60bfc8111aa4d210245c1e41" (type string) at path "price"
at model.Document.invalidate (C:\Users\RADIOLOGY\Projects\MERN_Course\backend\node_modules\mongoose\lib\document.js:2730:32)
at model.$set (C:\Users\RADIOLOGY\Projects\MERN_Course\backend\node_modules\mongoose\lib\document.js:1319:12)
at model.$set (C:\Users\RADIOLOGY\Projects\MERN_Course\backend\node_modules\mongoose\lib\document.js:1023:16)
at model.Document (C:\Users\RADIOLOGY\Projects\MERN_Course\backend\node_modules\mongoose\lib\document.js:148:12)
at model.Model (C:\Users\RADIOLOGY\Projects\MERN_Course\backend\node_modules\mongoose\lib\model.js:105:12)
at new model (C:\Users\RADIOLOGY\Projects\MERN_Course\backend\node_modules\mongoose\lib\model.js:4706:15)
at C:\Users\RADIOLOGY\Projects\MERN_Course\backend\routes\products.js:19:21
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use node --trace-warnings ... to show where the warning was created)
(node:6064) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejectingr by throwing inside of an async function without a catch block, or by rejecting a promise which was nection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.orgot handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode)promise rejections that are not handled will terminate the Node.js process with. (rejection id: 1)
(node:6064) [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
Please who can advise or check what went wrong here, or any solutions. I have checked countless times and compared my code with the one of the instructor, i couldn't find any error.
PLEASE HELP !!
(node:6064) UnhandledPromiseRejectionWarning: ValidationError: Product validation failed: price: Cast
to Number failed for value "60bfc8111aa4d210245c1e41" (type string) at path "price"
at model.Document.invalidate (C:\Users\RADIOLOGY\Projects\MERN_Course\backend\node_modules\mongoose\lib\document.js:2730:32)
at model.$set (C:\Users\RADIOLOGY\Projects\MERN_Course\backend\node_modules\mongoose\lib\document.js:1319:12)
at model.$set (C:\Users\RADIOLOGY\Projects\MERN_Course\backend\node_modules\mongoose\lib\document.js:1023:16)
at model.Document (C:\Users\RADIOLOGY\Projects\MERN_Course\backend\node_modules\mongoose\lib\document.js:148:12)
at model.Model (C:\Users\RADIOLOGY\Projects\MERN_Course\backend\node_modules\mongoose\lib\model.js:105:12)
at new model (C:\Users\RADIOLOGY\Projects\MERN_Course\backend\node_modules\mongoose\lib\model.js:4706:15)
at C:\Users\RADIOLOGY\Projects\MERN_Course\backend\routes\products.js:19:21
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use
node --trace-warnings ...
to show where the warning was created)(node:6064) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejectingr by throwing inside of an async function without a catch block, or by rejecting a promise which was nection, use the CLI flag
--unhandled-rejections=strict
(see https://nodejs.orgot handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode)promise rejections that are not handled will terminate the Node.js process with. (rejection id: 1)(node:6064) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future,
THE CODE
`const {Product} = require('../models/product');
const express = require('express');
const { Category } = require('../models/category');
const router = express.Router();
router.get(
/
, async (req, res) =>{const productList = await Product.find();
})
router.post(
/
, async (req, res) =>{const category = await Category.findById(req.body.category);
if(!category) return res.status(400).send('Invalid Category')
})
module.exports =router;`
The text was updated successfully, but these errors were encountered: