How to get all combinations of 2 or more lists to 1 request?

Lets suppose we have 2 lists and a request that receives 2 variables

list1 = [a, b]
list2 = [1, 2, 3]

request = {
url = localhost:8080
var1 = x
var2 = y

How can I send that request using all values combination for these 2 lists?

iteration1: x = a; y = 1
iteration2: x = a; y = 2
iteration3: x = a; y = 3
iteration4: x = b; y = 1
iteration5: x = b; y = 2
iteration6: x = b; y = 3

In code, we would have something like this

for (x in list1) {
___for(y in list2) {
______sendRequest(localhost:8080, x, y)

Hi @elefantecinza

Welcome to the forums!

You can combine the permutations of the two lists using TypeScript (enabled by clicking the drop down that says FQL on the top right corner of the Evaluate Block) in an Evaluate Block, then use a For Block to iterate through all the variables, passing in X and Y from the combined list like below:

TypeScript code for the Evaluate Block:

interface Combination {
  x: string;
  y: number;

const combinations: Combination[] = [];

for (const x of list1) {
  for (const y of list2) {
    combinations.push({ x, y });

I tried a lot of times and didnt get the solution. Thanks!

I dont know if I should open a new topic, but…

how the Evaluate block choose the result value to provide?

I mean… You didnt use a return statement to tell to the block that the variable “combinations” should be used as result of it

Hi @elefantecinza

Whatever the last value the script had will be returned. Hence why I put combinations; in the last line.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.