I
I
Ivan Antonov2015-02-07 17:59:27
Node.js
Ivan Antonov, 2015-02-07 17:59:27

No replace method in nodeJS?

has no method 'replace'
How to fix the error?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Antonov, 2015-02-07
@antonowano

toString() - needed. data is an object, much to my surprise.

fs.readFile(pathToFile, function(err, data) {
    var s = data.toString().replace('{{ name }}', 'antonowano');
    res.end(s);
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question