I´m writing a Node.js app which should make an HTTP request using "request" module and save the response in Parse with some parameters and so. I use setInterval() for the loop.
Problem is I'm getting always the same response, like it´s cached or something. If I do a cURL form my local machine I see the actual data, however the loop in Node.js seems to get always the same response.
EDIT with code:
//Loop
setInterval(function(){
try {
foo.make_request();
}catch(e){
console.log(e);
}
}, 30 * 1000); //30 secs
and my make_request function:
function _make_request(){
//Configure the request
var options = {
url: 'http://player.rockfm.fm/rdsrock.php',
method: 'GET'
};
//Start the request
request(options, function (error, response, body) {
if (!error && response.statusCode == 200) {
// Print out the response body
var artist = body.substring(0, body.indexOf(':'));
var title = body.substring(body.indexOf(':')+3, body.indexOf('@')-1);
console.log(artist + " - " + title);
//upload to Parse etc etc
}
});
}
module.exports.make_request = _make_request;