I have a schema problem. I dont get the right schema in my api. here is my api :
var Meetup = require(\'./models/meetup\');
module.exports.create = functio
If req.body
is undefined (as you wrote in the comments) then obviously new Meetup(req.body);
cannot populate the new objects with any data (like {name: 'Text input'} or anything else) since it is called with undefined
as an argument.
Make sure you use the body-parser and that you pass the correct data in your request.
Also, check for errors. Every callback that takes the err
argument should be in the form of:
module.exports.list = function (req, res) {
Meetup.find({}, function (err, results) {
if (err) {
// handle error
} else {
// handle success
}
});
}
How to track the problem:
console.log(req.body)
after new Meetup(req.body);
to know what you save