Include API Param only if condition is met?

Hello,

I have an API call (Woocommerce) with a few params needed.

Is it possible to only include a specific param if a condition is met? For example, a selector for viewing in stock, out of stock, or all products via stock_status param.

Woo throws an error if trying to submit a blank value for stock_status, so i’d like to remove the param from the API call entirely if All Products is selected.

Hope that makes sense!

In this case you would want to create a separate query that includes the status and call one or the other conditionally. You could accomplish this with a JS function.