The semantics of insomnia.execution.setNextRequest()
, request looping
#8250
-
Dear members of the Insomnia community, please help me solve the following problem related to a flow of request calls when running a collection/folder in Insomnia. Let's assume that there are three requests:
Now, the goal is to run the requests so that we discover all projects (using These are my observations which I made while trying to achieve the goal (using Insomnia v10.2.0 on macOS):
Having written all that, can someone give me a guidance to achieve the goal and help me close the gap I have in understanding how Cheers, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hello @janspudich, In short,
For your case, I assume it is allowed to:
You could try something like:
// get the next resource to send req b
const resources = insomnia.variables.get('resources');
const idx = insomnia.variables.get('idx') || 0;
const currentResource = resources[idx];
// do something you want
if (idx+1 < resources.length) { // redirect to self to collect risks
insomnia.variables.set('idx', idx+1);
insomnia.execution.setNextRequest('Request B');
} else { // start collect issues
insomnia.variables.set('idx', 0);
insomnia.execution.setNextRequest('Request C');
}
|
Beta Was this translation helpful? Give feedback.
Hello @janspudich,
In short,
setNextRequest
has following behaviors:For your case, I assume it is allowed to:
You could try something like:
Req A
, in script, set all resources as an array byinsomnia.variables.set…