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
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