waiyaki / postgres-express-node-tutorial

Repository hosting code for the "Getting Started With NodeJS, Express and Postgres Using Sequelize" blogpost.
MIT License
278 stars 103 forks source link

TypeError: Cannot read property 'create' of undefined #13

Open mostpalonen opened 3 years ago

mostpalonen commented 3 years ago

When trying to create the controllers for creating new todos I get the following error: "TypeError: Cannot read property 'create' of undefined" when calling the API from Postman.

The part of the code where the error happens: module.exports = { create(req, res) { return Todo .create({ # This is the problem part title: req.body.title, }) .then(todo => res.status(201).send(todo)) .catch(error => res.status(400).send(error)); }, };

I'm not super familiar with ES6 syntax so I really don't know if I need to refactor this code