Here is the code snippet I am using:
router.get('/image',(req,res,next)=>{
const fileName = "path_to.jpg"
res.sendfile(fileName,(err)=>{
if (err) {
next(err);
} else {
console.log('Sent:', fileName);
}
});
})
While this router works in Express 4 by sending the desired image successfully to the client, there is a warning from the server stating that "res.sendfile" is deprecated and recommending the use of "res.sendFile" (simply capitalizing the "f").
express deprecated res.sendfile: Use res.sendFile instead
However, when I make this change as suggested, my code no longer produces a 200 status but rather a 500 error. This happens with only the alteration of changing the letter case for "file".
Am I misunderstanding what the express warning is trying to convey?
I have checked the Express documentation and do not see any evident mistake in my code snippet... If there are additional details needed, please let me know.