Fallback for exceeding External API timeout

Hi Themeco Team,

I am very excited about exploring External API and Twig, which were integrated into the PRO Theme not that long ago. From my experience so far, APIs can sometimes be unavailable. And if this is the case, within that period of time the pages dependent on that data might not look nice at all. Creating fallback blocks to display when needed would be really helpful for awareness of site visitors.

How can we set conditions to display a fallback block instead of API content during external service interruptions? I guess we can use the Endpoint Timeout Settings for the External API to trigger a message if the API is unresponsive. Something like “Please wait a few minutes and try reloading the page. Service is temporarily unavailable.”

Could you please share your advice and guidance on what is the best practice to set up such a condition?

I would start with the API Tester. In the Error block, you can post your error messages there and style it from there. Then in the success area you can do what you would display. You will need to setup a Dynamic Content looper using {{dc:looper:field key="response"}} to then loop as you normally would. You’ll notice in the API Tester it just outputs that data in a raw content element. See how the API tester works to get a better idea on this. Have a great day.

1 Like

Thank you, Charlie, for bringing that up. I will explore what is possible there.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.