Handling API Call exceptions

I am calling an API get product details from barcodelookup.com, in most cases I get the details but when a product is new and the provider doesn’t have the product in their DB I get a blank response, is there a way handle this exception in Adalo when the API response is blank?

@Victor any suggestions?

1 Like

Hi Bhanu,

I have no experience using the API you mention but might have a solution.

Maybe you could set up an invisbile input field, make the API call and set an action to add the result to the invisbile input field. Then set a ‘no results’ gif or image to only show if the invisible input is empty. Do you think that would work?

@crmorris2 unfortunately that wouldn’t work because when there’s no response Adalo wouldn’t tell me that there’s no response.

I might have to handle this outside Adalo and send a dummy response to custom action to recognise these events.

Will update here if I am able to handle it, might be helpful others.

Hi Bhanu,

I would have to disagree in this instance, getting no response can be handled with an action to update an input field, if their is no response then the field stays blank and therefore allowing you to control other fields and actions. I have just set an example up and it worked as I imagined.

See cloneable example. https://previewer.adalo.com/f3400be5-5c32-4d59-ba50-fe7147339d34

Hope this does the job for you :+1:

1 Like

@crmorris2 unfortunately not, based on the screenshot below, I can’t use the return values in a custom action to determine whether there’s a response from the API yet.

The workaround though is to create a temp collection from the response and then check the values in the temp collection to see if the values are blank (which is too long winded and defeats the purpose of using external collections :frowning: )

What is wrong with my solution? Have you not tried it?

how do I determine when there’s no response from a custom action?

Check my post, I added a link to a cloneable app that has everything you need.

@crmorris2 apologies, the clonable version assumes you know the response to show “No Results Found”, in my case I am using an external API call to fetch records and I can’t use them unless I store results first into a collection.

Would you be able to connect your clonable version to version to external API and confirm if this works please? I’d love to use it and it solves my biggest roadblock

It is connected to an external API via custom action (the same barcode one you are using), does it not show in the clone?

Apologies, I did’t realise custom actions do not copy over in a clone. PM me your email address and I will add you as a team member in the app so you can see how it is built.