JavaScript Building a MEAN Application Setting Up MongoDB Using Models in Your Application

Dennis Klarenbeek
Dennis Klarenbeek
17,167 Points

Get the Todo.find is not a function error

I'm following along with the teachers documents but I get an error when I try to get the json object by the postman application.

The following error code I get:

TypeError: Todo.find is not a function

Can somebody help me with this?

2 Answers

Daniel Li
Daniel Li
15,244 Points

Check in src/models/todo.js

module.exports = model;


var Todo = require('../models/todo');
Ran ShemTov
Ran ShemTov
14,148 Points

When the "not a function" error occures, It probably means one of these things:

  • You didn't adress it right: Maybe lower or uppercase error that creates a difficulty for the script finding your object.
  • Since it's node.js, maybe you didn't "require" right, maybe the path or maybe a typo.

"not a function" actually means (usually) that the script couldn't find your object, thefore it couldn't fit the method (in your case "find") to the object, therefore it says "not a function"