Forum Academy Marketplace Showcase Pricing Features

Finally, my API data refreshes without page reload- How I got it to work

Thanks @w.fly
For me, it finally turned out that I just have to re-display the list in a workflow, with or withoud a date header in the source API apparently.
I was pretty sure I havetested this before but apprently not…

2 Likes

Hey @sam, did you get an answer?

I’m currently developing an app that heavily relies on the SQL Connector plugin and encountered the same problem then you. I found my answer on the forum; it’s quite simple.

In the SQL query you want to be able to refresh, simply add an extra parameter (that won’t be part of the SQL statement). I named mine “dummy” and the type is number.
Now, whenever you need to reference this query, in addition to your necessary parameters, you include the dummy one with the value Current date/time:extract UNIX. As mentioned above, this will make Bubble repeat the query instead of just sending you back the cached result.

2 Likes

Hi @julienallard1

Thank you so much for your response.

Yes, I got it worked.

After couple of hard working days later I realized that time is the only parameter we have which keeps changes.

Anyways again thank you so much for the response you gave. If we have people around us like this to give helping hand, We can keep going with bubble.

1 Like

Is this still working because I can’t seam to make my api calls refresh

The SQL method with a dummy parameter based on a random value like todays date in ISO format worked a charm for me today. Thank you so much.

1 Like

Yea, it still works. Make sure the format of the date is correct and that it’s in the header. Here’s what the call looks like on my end. Hope this helps.

Screen Shot 2020-07-31 at 9.04.05 AM

Screen Shot 2020-07-31 at 9.04.13 AM

1 Like

@w.fly

Hello!
Just see your screenshot and I’m wondering what’s your fomule/pattern to get the date as an API compatible ISO ?
I’m currently using a paid plug-in just to do this conversion!
Moreover, are you able to do this the other way around? I mean getting a date from this ISO format to Bubble date? Because I’m currently unable to save data from API call as date!

Thank you, this will help me a lot!
Have a good evening :slight_smile:

Luckily it’s a built in Bubble format - Here are the steps:

Screen Shot 2020-08-03 at 9.38.46 AM

Screen Shot 2020-08-03 at 9.39.02 AM

As far as doing it the other way around, I assume you would make choose “Date” when you go to set up the API Return Values - For me, “date” pulls in the right date format to work with Bubble. See screenshot.

Hope this helps.

1 Like

Great tip, this just saved me a lot of work with custom states.
Thanks!

w.fly thanks very much ! You save me a ton of work !

Regars

1 Like

@w.fly Thank you so much for the updated header trick! It’s perfect and has saved me further headache. :smile:

1 Like

An update to this very old post – This method has been working faithfully for me for years, however I have noticed that every now and then it “doesn’t work”.

Turns out, it’s due to the way the “Current date/time” function natively works in Bubble. When you load a page, it gives the current date and time… however, if you keep the page open for 5 minutes, the current date/time is still what it was when you loaded the page initially.

This can lead to an issue where this worked… then suddenly “doesn’t work” (“hmm, the data is still stale… what gives!?”).

So, the new, free, 5 minute solution, that has proven rock solid for me is the following:

  1. Download the “Current date/time” plugin
  2. Place the plugin anywhere on the page you’re working on.
  3. Reference the new plugin vs. the native “current date/time” in Bubble.
    OLD *using Bubbles native “current date/time”:
    Screen Shot 2021-06-18 at 2.15.08 PM

NEW:
Screen Shot 2021-06-18 at 2.12.14 PM

This ensures that no matter how long a page has been opened, every time you fire off another API call, the “current date/time” is absolutely the current date/time, thus ensuring fresh data with every call.

Cheers!

4 Likes

Quick question @w.fly

Is it also possible to add this “(header) date” to an API call from a paid plugin? I am using the Stripe Marketplace Plugin and also having the issue with the data that is not refreshing.

Thanks for the help.

If it’s not in the Bubble API Connector, then I don’t believe so :confused: See image for where I placed mine.

If you don’t have access to that, I am unsure what you could do… Bubble does caching automatically for you and I really haven’t found a way other than the one above to forcefully break the cache.

2 Likes

You’re God :wink: All works super-fast and stabile.

Thanks, you probably saved me days of research!

Cheers!

I’m wondering why you can’t just use “Calculate formula > Random string” instead of date?

1 Like

In my case, the API I was using (Wrike) accepted Date as a header – I don’t believe I could’ve just sent it some random string.

Is this not in the docs? This was the exact problem I was experiencing. I was creating a poor-mans polling utility with a repeat every x with a conditional check. I’d really suggest getting this into the docs if it’s not, I didn’t find it at least. Thanks for the find!

I believe you can

@w.fly God Bless you mate! I’ve spent 3 days figuring out how to update the repeating group with info from API and finally found your thread. I wish I’ve found it earlier!