So I am running a small test application to return the contents of a markdown file in html when a route is visited. I am using marked to render the markdown (https://github.com/chjj/marked).
Here us what I have so far -
app.get('/test', function(req, res) {
var path = __dirname + '/markdown/test.md'
var file = fs.readFile(path, 'utf8', function(err, data) {
if(err) {
console.log(err)
}
return data.toString()
})
res.send(marked(file))
})
When I navigate to localhost:3000 I'm getting -
TypeError: Cannot call method 'replace' of undefined Please report this to https://github.com/chij/marked.
I'm fairly certain I'm trying to send a string, and it res.send('Hello World!') works just fine. Sorry I'm new to both Node and express so I'm still figuring things out. Any help is much appreciated.