Here is my Snippet of Code, Where I used Express router and Mongoose Model .
I'm Unable to Access id parm .
router.delete('/task/:id', function (req, res) {
Task.remove({ did: req.parms.id }, (err) => {
if (err) {
res.send(err);
}
});
});
This is the Error I received
TypeError: Cannot read property 'id' of undefined at F:\NS\routes\tasks.js:11:33 at Layer.handle [as handle_request] (F:\NS\node_modules\express\lib\router\layer.js:95:5) at next (F:\NS\node_modules\express\lib\router\route.js:131:13) at Route.dispatch (F:\NS\node_modules\express\lib\router\route.js:112:3) at Layer.handle [as handle_request] (F:\NS\node_modules\express\lib\router\layer.js:95:5) at F:\NS\node_modules\express\lib\router\index.js:277:22 at param (F:\NS\node_modules\express\lib\router\index.js:349:14) at param (F:\NS\node_modules\express\lib\router\index.js:365:14) at Function.process_params (F:\NS\node_modules\express\lib\router\index.js:410:3) at next (F:\NS\node_modules\express\lib\router\index.js:271:10) at Function.handle (F:\NS\node_modules\express\lib\router\index.js:176:3) at router (F:\NS\node_modules\express\lib\router\index.js:46:12) at Layer.handle [as handle_request] (F:\NS\node_modules\express\lib\router\layer.js:95:5) at trim_prefix (F:\NS\node_modules\express\lib\router\index.js:312:13) at F:\NS\node_modules\express\lib\router\index.js:280:7 at Function.process_params (F:\NS\node_modules\express\lib\router\index.js:330:12) at next (F:\NS\node_modules\express\lib\router\index.js:271:10) at F:\NS\node_modules\express-validator\lib\express_validator.js:291:5 at Layer.handle [as handle_request] (F:\NS\node_modules\express\lib\router\layer.js:95:5) at trim_prefix (F:\NS\node_modules\express\lib\router\index.js:312:13) at F:\NS\node_modules\express\lib\router\index.js:280:7 at Function.process_params (F:\NS\node_modules\express\lib\router\index.js:330:12)