var express = require('express');
var router = express.Router();
const MongoClient = require('mongodb').MongoClient;
/* GET home page. */
router.get('/', function (req, res, next) {
res.render('index', { title: 'Express' });
});
router.post("/signup", function (req, res) {
console.log("first_name: " + req.body.first_name)
console.log("last_name: " + req.body.last_name)
MongoClient.connect("mongodb://localhost:27017", function(err,Client) {
if(err) {
console.log("ERROR");}
else{
console.log("CONNECTED")
}
});
res.send("HII")
})
module.exports = router;
OUTPUT
Here the data is recieved from a form but the function for checking the connection status of mongodb is not working, and no errors are showing
i am a beginer in web devolopment and dont have know much about how its connected and all.
please help me out
2
Answers
Try this code once :