Reputation: 4368
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!
Upvotes: 0
Views: 1692
Reputation: 10659
As button
tag don't have any action attribute
try to replace it with anchor
tag.
try to replace button(action="/download", type="button") Download Me!
with
a(href='/download') Download Me!
Upvotes: 2