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

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

Description

@mostpalonen

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions