I am making an http request which should run after every one minute. Below is my code
var express = require("express");
var app = express();
var recursive = function () {
app.get('/', function (req, res) {
console.log(req);
//Some other function call in callabck
res.send('hello world');
});
app.listen(8000);
setTimeout(recursive, 100000);
}
recursive();
According to the above code, I must get response after every one minute. But I am getting Error: listen EADDRINUSE. Any help on this will be really helpful.
This code makes http requests every minute:
var http = require('http');
var options = {
host: 'example.com',
port: 80,
path: '/'
};
function request() {
http.get(options, function(res){
res.on('data', function(chunk){
console.log(chunk);
});
}).on("error", function(e){
console.log("Got error: " + e.message);
});
}
setInterval(request, 60000);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With