I follow a tutorial and have no clue what's wrong. There's no error in my cmd at all. When I open localhost:3000 I saw this error Cannot call method 'get' of undefined and couldn't load the post in my posts collection.
var express = require('express');
var router = express.Router();
var mongo = require('mongodb');
var db = require('monk')('localhost/nodeblog');
/* Homepage blog posts */
router.get('/', function(req, res, next) {
var db = req.db;
var posts = db.get('posts');
console.log(posts)
posts.find({},{},function(err,posts){
res.render('index',{
"posts":posts
});
});
});
My jade
block content
if posts
each post, i in posts
h1=post.title