No matter what I try, I can\'t get rid of this error and I have several other features in my application that create instances of Mongoose Models which look almost exactly l
I should have posted more of my code to help diagnosis this issue. It turns out my /project/create
route was the issue.
I also had another route to view a project that was /project/:id
. I supposed the /create
part of my route was interfering with this logic so I changed the paths in my routes and all is working just fine now.
// Before
router.get('/projects', projects); // view all projects
router.get('/project/:id, project); // view a project
router.post('/project/:id', projectUpdate); // update a project
router.post('/project/create', projectCreate); // create a project
router.post('/project/delete/:id', projectDelete); // delete a project
My routes for this feature of my app now look like this:
// After
router.get('/projects', projects); // view all projects
router.get('/project/:id', project); // view a project
router.post('/project/', projectCreate); // create a project
router.post('/project/:id', projectUpdate); // update a project
router.post('/project/delete/:id', projectDelete); // delete a project
I learned a lesson today! Thanks for the help @Hypermattt.