user3668129
user3668129

Reputation: 4820

TypeError: res.Send is not a function

I have this function:

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);
})

for unknown reason I'm getting the following error:

TypeError: res.Send is not a function

I looked at this post: https://stackoverflow.com/questions/44176021/nodejs-res-send-is-not-a-function

and it's looks like other bug.

How can I fix it ?

Upvotes: 0

Views: 4359

Answers (1)

xate
xate

Reputation: 6379

TYPO

res.Send(counter); => res.send(counter);

https://expressjs.com/en/api.html#res.send

Upvotes: 5

Related Questions