-
Goal: To run event handler if, the value of the returned query response has a value of: {}
-
Steps: I have tried statements like:
{{query1.data[0].data[0].value == {} }}
{{query1.data[0].data[0].value == 0 }}
{{query1.data[0].data[0].value == '' }}
However even when the query1. response comes back with a value of {}, the expression stills says 'false'
Is there a way to reference an empty object as a boolean statement into an event handler?
Solved with JS:
// Access the response data from the already-triggered 'query1' query
const response = query1.data;
// Check if the 'value' field in any of the response items is an empty object
const isValueEmptyObject = response.some(
item => item.data && item.data.some(dataItem => JSON.stringify(dataItem.value) === '{}')
);
// Trigger 'query2' if 'value' is an empty object
if (isValueEmptyObject) {
query2.trigger();
}
1 Like
Thanks for sharing @Ian_Stack!