Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make a request every one minute with Node.js

Tags:

I began to develop in Node.js today and I think an application that performs several requests to know the server uptime. I need every request completion the function is performed again as a while loop.
Is it possible to do this in Node.js?

My basic code

var http = require('http');
var request = require('request');

request({
    url: "http://www.google.com",
    method: "GET",
    timeout: 10000,
    followRedirect: true,
    maxRedirects: 10
},function(error, response, body){
    if(!error && response.statusCode == 200){
        console.log('sucess!');
    }else{
        console.log('error' + response.statusCode);
    }
});

PS : Sorry if it's a stupid question or duplicate