app.get("/add",function(req,res){
//
//
MongoClient.connect(shujukuURL,function(err,db){
if(err){
console.log(err);
console.log("");
return;
}
res.send("123")
//
db.collection("user").insertOne({
"name":"node.js",
"age":13
},function(error,result){
if(error){
console.log(error);
console.log("");
return;
}
res.send("");
db.close();//
})
})
});
problem: after the above code connects to the mongodb database, you can add a piece of data like the database, but the res.send () method is not executed in the browser, and the cmd command box reports an error. Have you ever encountered similar problems? please take a look, thank you.