Query array in optionlist logic for networks

Hi,

I’m trying to refine our optionlist logic for selecting networks:

Currently I have:

for(var x=0;x < data.networks.length; x++) {
if (data.networks.dhcpServer == true && data.networks.visibility == “public” && data.networks.labels.length > 0) {
results.push({name: data.networks.name, value: data.networks.id});
}
}

Which works, however I would like to refine.

Basically I want to match the contents of data.networks.labels so if a label is set as “provisioning” it’s selected.

I have tried data.networks.labels == “provisioning” but it does not pick up. I have tried data.networks.labels.includes (‘provisioning’) but the query errors as it does not like includes,

When I query the API, I say it’s: -provisioning.

Any ideas on the correct syntax to use?

Hi Chopper,
Certainly, please attempt to access the first element of the array using data.networks.labels[0]. This should provide the desired data from the array.

Thanks
Velan

Thanks that is now working.