Add data after mongodb node.js connection

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.

Mar.18,2021

the problem should be that you used res.send twice, and the error prompt in cmd was made in line 49 of app3.js.


res.send ("123") just remove it here. You forgot to delete it in this test.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf2764-31de7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf2764-31de7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?