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

0

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.