76
rated 0 times
[
78]
[
2]
/ answers: 1 / hits: 17191
/ 8 Years ago, sat, december 31, 2016, 12:00:00
I have code that reads the file 'example.js' and sends it to the client.
app.get('/mods/example.js', function(req, res) {
fs.readFile('./mods/example.js',
{encoding: 'utf-8'},
(err, data) => {
if (!err)
{
res.send(var example = new Mod(); + data);
}
});
});
The problem is how do I send the response as a javascript file?
When I open the file in the web browser it is an html file not a javascript file.
Thanks in advance!
More From » node.js