In my index.jade file I have
button(action="/download", type="button") Download Me! and within my index.js I have
var express = require('express'); var router = express.Router(); /* GET home page. */ router.get('/', function(req, res, next) { res.render('index', { title: 'Express' }); }); router.get('/download', function(req, res){ var file = __dirname + '/img/desktop-cover.jpg'; res.download(file); console.log(file); }); module.exports = router; I'm trying, on click of the button, to initiate the router.get('/download') that will download an image I have.
I may of misunderstood some of the documentation and i'm not sure why it isn't working.
Thanks!
res.download(file);so when I click on the button the action is/downloadthat i've created a route for, and then the route will deliver a fileconsole.log(file);beforeres.download(file);