I have a Node.js app running with Expressjs. I have the typical setup right now, using view jade files and route js files to process GET and POST requests. An example is as follows:
router.post('/postaction', function(req, res) {
// elements from the actual jade view itself
var one = req.body.from;
var two = req.body.to;
// do something
});
router.get('/getaction', function(req, res) {
// elements from the actual jade view itself
var one = req.body.from;
var two = req.body.to;
// do something
});
This works, I can carry out GET and POST requests. For example, a button might invoke the POST action. My question is, how can I use a separate script or npm module to invoke the same GET and POST requests without having to do it via the views? Ideally, I would have something like this:
somescript-get <param1>
somescript-post <param1> <param2>
with the params being akin to req.body.from and req.body.to. Essentially, I am looking to emulate the info from the page without having to use the page itself.
I am new to Node.js and would really appreciate some help. Please point out if I haven't explained something enough and I'll try to.
Thank you