Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NODEJS: Send a file and data at once

This is what I got. It works great but I'd like to be able to send a file and data (JSON), to the client when he logs in my website. Is there any way to combine that?

app.get('/', function (req, res) { 
    res.sendfile(__dirname + '/index.html');
});
like image 229
RainingChain Avatar asked Jun 30 '26 15:06

RainingChain


1 Answers

You can't send 2 files at once. But you can embed the JSON inside the html by using a template library with ejs.

like image 65
RainingChain Avatar answered Jul 03 '26 03:07

RainingChain



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!