0
collection.find({"topicname":topicname},function(err,result){ 
if(result){   
    console.dir("Success from database =\n"+result.toString());
    console.dir(result);
    console.log("This is it"+result);
    res.send("Hello "+result);
}
});

The result is displayed in console in Json format, but when fetched in the browser, it displays Hello [object Object]. Database used is MongoDb

Deesha
  • 37
  • 10

1 Answers1

1

res.send("Hello " + JSON.stringify(result));

This converts the JSON object into a String and will then render it appropriately on your page when concatenating with another String as you are doing.

JSON.stringify

Mike
  • 10,297
  • 2
  • 21
  • 21