Node Express get problem

Asked

Viewed 42 times

0

I’m trying to list the menu record in my Mongodb database and am not succeeding, but when I list the Restaurant records I succeed, all two collections are in the same database, why is this happening?

This is my method that list all Resturant

exports.get = (req, res, next) => {
    Restaurant
    .find({})
    .then(data => {
        res.status(200).send(data);
    }).catch(e => {
        res.status(401).send(e);   
    })

};

And this is the method for listing menu entries

exports.getMenus = (req, res, next) => {
    Menu
    .find({})
    .then(data => {
        res.status(200).send(data);
    }).catch(e => {
        res.status(401).send(e);   
    })

};
  • Is there an error? The variable exports is being exported in the module?

1 answer

0

It seems that getMenus is a method not defined by the system, but get yes.

What do you think about doing like this?:

getMenus = exports.get = (req, res, next) => {
    Menu
    .find({})
    .then(data => {
        res.status(200).send(data);
    }).catch(e => {
        res.status(401).send(e);
    })
};

Browser other questions tagged

You are not signed in. Login or sign up in order to post.