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);
}
});
结果以Json格式显示在console中,但在浏览器中获取时,它显示Hello[object object]。使用的数据库为MongoDb
res.send(“hello”+json.stringify(result));
这会将JSON对象转换为字符串,然后在与另一个字符串连接时将其适当地呈现在页面上,就像您正在做的那样。
json.stringify