Skip to content
This repository has been archived by the owner on Nov 14, 2022. It is now read-only.

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

Open
mostpalonen opened this issue Jun 4, 2021 · 0 comments
Open

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

mostpalonen opened this issue Jun 4, 2021 · 0 comments

Comments

@mostpalonen
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant