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:

That`s even better - many thanks!