I'm trying to trigger a file download when a POST request is sent to my server. Here is what I tried:
router.post('/generate', function (req, res) {
console.log('THIS IS RUNNING');
var file = __dirname + '/blah.txt';
res.download(file);
});
However, the res.download(file);
doesn't seem to be doing anything. When the browser sends a /generate
POST request, nothing gets downloaded. I know for sure that the function is running because the console is logging that message.
Any help would be appreciated!