Closed anastasiaalt closed 8 years ago
I have a route for posts and a model set up with a schema for posts. I also created a collection in my database from the command line with a piece of post data in it. When I got to the route, I get a blank page that just says [ ]
https://github.com/anastasiaalt/finalProject/blob/master/app.js https://github.com/anastasiaalt/finalProject/tree/master/models
app.get('/posts', function(req, res){ mongoose.model('posts').find(function(err, posts) { res.send(posts); }); });
I tried creating new collections in the command line, creating collections/models totally through the model files, etc. Nothing is working
Update your code to use the Post model .
Post.find({}, function(err, posts){ res.send(posts); });
I have a route for posts and a model set up with a schema for posts. I also created a collection in my database from the command line with a piece of post data in it. When I got to the route, I get a blank page that just says [ ]
https://github.com/anastasiaalt/finalProject/blob/master/app.js https://github.com/anastasiaalt/finalProject/tree/master/models
I tried creating new collections in the command line, creating collections/models totally through the model files, etc. Nothing is working