Node.js controlling no of post calls per second -
i subscribing inhouse api (post request) restricts me make 5 calls per second.
node.js being used make these rest api calls.
how write code restrict no. of api calls invoked per second ?
use setinterval(makeapicall, 200);
execute api calls every 200 milliseconds.
every execution of makeapicall
function make 1 call queue.
var queue = [ { arg1 : 'arg1value', arg2 : 'arg2value' }, { arg1 : 'arg1value', arg2 : 'arg2value' } ]; setinterval(function() { var arguments = queue[0]; // api call function, using arguments makeapicall(arguments.arg1, arguments.arg2); // remove queue queue.splice(0, 1); }, 200);
Comments
Post a Comment