var express = require('express');
var router = express.Router()
var MongoClient = require('mongodb').MongoClient
/* GET home page. */
router.get('/', function(req, res, next) {
res.render('index', { title: 'Express' });
});
router.post('/submit', (req, res, next)=>{
MongoClient.connect('mongodb://localhost:27017', function(err, client){
if(err){
console.log('Error')
}else{
console.log('DB Connected')
}
res.send(req.body)
})
})
module.exports = router;
I was trying to connect to the database, but idk why it not connecting. rn, im stuck here.
I was trying to connect to the database, but idk why it not connecting. rn, im stuck here.
New contributor
Jackson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.