Can you detect when an API call has failed due to loss of connectivity

I have a few apps that extensively use API calls to load data. I use both action outputs and backend queries to load the data; however, I have the same issue using both. If the user loses connection when they load the page / trigger the action that calls the API, then the code ceases execution at the API call action and the user is forever presented with the loading widget until they try to take another action to refresh the screen (which will work if they have connectivity).

Is there a way to set a timeout on API Calls to try to abort them if they fail?

For example, if I was using javascript I'd set a request timeout to be 3 seconds, then call the error state if no response was received. Does anyone know how to do this in FF?

5 replies