Skip to content

Ch. 5 - complications due to use of sendFile() (the recommended express method) #40

@murshedchoudhury

Description

@murshedchoudhury

As a result of moving over to sendFile(), I had to add __dirname to the path :. sendFile(__dirname+'...'), to get through the initial few pages of the chapter, otherwise I kept getting the "express deprecated res.sendfile ..." warning.

This was fine until pg. 62, where you separate out the sendfile endpoints. Here, the only workable solution I've found is to add a new object to the static.js file :. var path = require('path') and use its join method to cobble together a usable path for sendFile() :. res.sendFile(path.join(__dirname,'../relative/path/to/post.html').

The method mentioned in the book works fine, but since it is deprecated, I thought I'd try and learn the newer method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions