Reputation: 1020
I am constantly getting:
express deprecated res.sendfile: Use res.sendFile instead
here is my code:
app.get('/*', function (req, res) {
var myUrl = req.url.split('/')[1];
myownfunction(myUrl, function (err, rows) {
if (rows.length != 0) {
res.sendfile('views/article.html');
}
else
{
res.sendfile('views/404.html');
}
});
});
I changed the sendfile
to uppercase sendFile
, but it breaks.
what should i do?
when I run my code:
app.get('/upload', function(req, res){
res.sendFile('views/upload_file.html');
});
I get this error: TypeError: path must be absolute or specify root to res.sendFile
Upvotes: 0
Views: 400
Reputation: 20088
Use path.join() function to configure file path.
app.get('/upload', function(req, res){
res.sendFile(path.join(__dirname,"views/upload_file.html"))
});
Upvotes: 1