我有这个功能:
app.get('/counter', function (req, res) {
console.log('/counter Request');
var counter = 0;
fs.readFile(COUNTER_FILE_NAME, function(err, data) {
counter = data;
});
console.log('Read Counter: ' + counter);
counter = counter + 1;
// delete old file
fs.unlink(COUNTER_FILE_NAME, function (err) {
if (err) console.log('Cant chagne old counter file');
});
fs.appendFile(COUNTER_FILE_NAME, counter, function (err) {
if (err) if (err) console.log('Cant create new counter file');
});
console.log('Change Counter To: ' + counter);
res.status(200);
res.writeHead('content-type','text/plain')
res.Send(counter);
})
原因不明我收到以下错误:
TypeError: res.Send is not a function
我查看了这篇文章: https://stackoverflow.com/questions/44176021/nodejs-res-send-is-not-a-function
它看起来像其他bug。
我该如何解决?
答案 0 :(得分:4)