Error: No default engine was specified and no extension was provided. in the browser

By Surendra

I am using mongo with node.js, I am using mongodb npm package to connect with db and my code as follows.

var express = require('express');
var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/STUDENT";
var app = express();
console.log('jdg jhahg');
MongoClient.connect(url, function(err, db) {
  console.log("Connected correctly to server");
  findDOcuments(db);
  db.close();
});
var entireDoc = '';
var data = function(data, id){
  if(id == 'records'){
    entireDoc = JSON.stringify(data);
  }
}
var findDOcuments = function(db) {
  // Get the records collection
  var collection = db.collection('records');
  // Find some records
  collection.find({}).toArray(function(err, docs) {
    console.log("Found the following records");
    console.log(docs);
    data(docs,'records');
  });
}
app.get('/getInfo', function(req, res){
  res.render(entireDoc);
})
app.listen(3000);

The above code while rendering in browser throwing the above error in the browser. Can any one help in this.

Source: Stack Overflow

    

Share it with your friends!

    Fatal error: Uncaught Exception: 12: REST API is deprecated for versions v2.1 and higher (12) thrown in /home/content/19/9652219/html/wp-content/plugins/seo-facebook-comments/facebook/base_facebook.php on line 1273