i am following a project by udemy and i am having a TypeError: Cannot read property 'db' of undefined
var express = require('express');
var router = express.Router();
var mongo = require('mongodb');
var monk = require('monk');
var db = monk('localhost:27017/nodeblog');
/* GET home page. */
router.get('/', function(req, res, next) {
var db = req.locals.db;
var posts = db.get('posts');
posts.find({},{},function(err, posts){
res.render('index',{
"posts": posts
});
});
});
module.exports = router;
via Cobat
No comments:
Post a Comment