Hi. First of all, no, I will not ask about synchronous requests o sequential
I am making a loop where within it I generate differents object and send it through pm.sendRequest (). The problem is that when the array is very large I saturate my server. I have tried several methods (below you will see it) but it is not respecting the wait (I observe it from Kibana).
var maritalStatus = ['single', 'married', 'divorced', 'not indicated']
var obj = {"status" : "aux"}
function timeOut (milliseconds){
setTimeOut(() => {
console.log('Waiting');
}, milliseconds);
};
for (const i in maritalStatus){
obj.status = maritalStatus[i]
function timeOut(2000); //<- The wait
pm.sendRequest({
url: 'https://',
method: 'POST',
header: { 'Content-Type': 'application/json' },
body: {
mode: 'raw',
raw: obj
}
}, function (err, response) {
if (err) {
console.log(err);
} else {
console.log(response);
}
});
}
In the Postman´s console I observe that the internal requests (sendRequest ()) are painted first and then the “waiting” logs. I observe in Kibana that the requests have arrived with a difference of thousands of seconds not with at least two seconds.
Another way of waiting that I tried to try but it didn’t work.
function wait (millis){
var t = new Date().getTime();
while (new Date().getTime()< t+millis);
};
In my example I have put a simple case but in reality hundreds of Postman´s requests execute thousands of SendRequest().
Any ideas?