I'm trying to sendFile
index.html from inside my client directory which is at the same level as my server directory, and getting the following error:
TypeError: undefined is not a function
at Object.handle (/myapp/server/routes/routes.js:31:7)
This is line 31 of my routes.js: res.sendFile(fileName, options, function (err) {
Full function
dashRouter.get('/', function(req, res) {
// res.send('dashboard!');
var fileName = 'index.html';
var options = {
root: __dirname + '../client/dashboard/',
dotfiles: 'deny',
headers: {
'x-timestamp': Date.now(),
'x-sent': true
}
};
res.sendFile(fileName, options, function (err) {
if (err) {
console.log(err);
res.status(err.status).end();
}
else {
console.log('Sent:', fileName);
}
});
});
return dashRouter;
My folder structure:
Do you know why I'm getting that undefined error on the sendFile
line?
Aucun commentaire:
Enregistrer un commentaire