Removing null values from a list

Is there another way to remove null elements from a list than the one below?

i.e. [“0”, “1”, “2”, null, “3”, “4”] → [“0”, “1”, “2”, “3”, “4”]

Even though this works in principle, it somehow stalls my overall flow (it never ends).

As the list is used in a request, I was able to implement a workaround with the following pre-request script, which removes null elements from a list variable.

var str = pm.variables.get("myList");
var list = JSON.parse(str);
list = list.filter(element => { return element !== null; });
str = JSON.stringify(list);
pm.variables.set("myList", str);

Hi @adrian-g !

I just wanted to add there is another way of doing this in Flows itself if you don’t want to use the pre-request script using the $filter() function:

1 Like

That`s even better - many thanks!