Tuesday, 4 April 2017

Why does the server count double entries?

var http = require('http');
var counter = 0;
var server = http.createServer(function(req, res) {
        counter++;
        res.write('Used: ' + counter);
        res.end();
}).listen(8888);

Why does the server count double entries? I open in Chrome localhost:8888 and I have "Used: 1". This is ok, but if I refresh browser or open again, then I have "Used: 3", "Used: 5", "Used: 7" etc. Why?



via keweyij

No comments:

Post a Comment