is there a best practice or nifty way to show or hide a layer, alternatively navigate to a new scene, depending on the response from a call to an api call (interface asset).
In my case I would want to show a layer if there is content (text) in the response from the call to the external api. If there is no content ("") I would like to skip-ahead to another layer in my experience by hiding the current layer.
I have an issue with this approach that might be related to how api:s handle stuff differently.
The endpoint for my api request delivers a list, an array, containing a few objects. But sometimes this array is empty, like [], but still identifies as a completed request (http status 200 ok).
So my question is now: How can I create a condition in where I check if the array itself is empty rather than if an object in the array is empty?
In my first attempt I made a condition like this: "text of showcase_texts Equals but as text itself does not exist when the array is empty the condition does not seem to work.
Is it wrong or unorthodox for an api to return an empty array? Should it rather return a status 404?
Either way it would be interesting to know if it is possible to actually make conditions that check wether the array is empty or not. Perhaps some kind of count?
That would be the best indeed if you’re the master of your API.
A count value would help you to set up 2 conditions, one with count==0 and one with count>0.
We provide this property on our Excel Interface Asset but for an API you have to implement it yourself.