var express = require('express');
var router = express.Router();
/* GET home page. */
router.get('/', function(req, res, next) {
res.render('index', { title: 'Express' });
});
router.post('/', function(req, res, next){
res.send("post works");
});
module.exports = router;
This is my index.js file. I used express to create an app, add my own jade file which has a form in it. Can i define a post method like that? I am new to node.js so dont really have a grasp on how this works?
I would like to add i am trying to save data to a mongodb instance.
Update: 26/11/18
I got the solution after i got the answers given down below, I am adding the GitHub link.
I have added the working files to it.