Error handling for the API and restart again from same the point

Hello bubbler’s,

I have doubt, about handling the API error and also starting the workflow where we left.
So in my app, we call the API from almost every page and we have “session-token” to be sent through each API call(which suppose to expire afetr every 15-20min).
So have to check after each API response that if API error contains “Incorrect session token” then will relogin the user and create fresh “session-token”.



I have set custom state on page if error occurs will trigger that event and call the custom event named “relogin”.

Now help i needed over here is, i want to start the workflow where we left, i mean calling the API which failed because of “Incorret session-token”. After getting fresh session token how can i restart where i left the workflow.

Also i have this requirement through all the pages.
Can someone guide me or correct me to achieve this ?
Any help is appreciated.
Thank you

That looks like a big, big workflow. Is there no way to break it down?

Also, if you’re calling the same API every so often, Bubble might cache that call and not actually make the call AND Bubble will give you no indication that its cached. To avoid that, add a parameter to the call where you can send a number that is always changing, like the time.

@rico.trevisan
Thank you for your quick reply.
There are few API which we might call frequently. But not sure about adding that parameter to the call. Need to discuss with team.

About breaking down the workflow , most of the pages from app have long workflows as we are handling the diff ui elements based on width of page.

But can you guide about handling error of API’s and it should be silent and user should not be aware of we are taking fresh token in backend and then start where used had left?

I used to build apps like that and then I came up with a little framework that has helped me a lot: Single-page application framework: App Shell [free tutorial]

My tutorials are based on the old engine, but the principles still hold. @neilpierce has a more up to date one: https://www.youtube.com/watch?v=0A7kcxDU4b4.

@rico.trevisan
How SPA will help handling API errors? Are you suggesting the SPA for