I have code that reads the file example.js and sends it to the client.
app.get('/mods/example.js', (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 a HTML file, not a JS file.
Thanks in advance!
res.typemethod in the official docs.