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

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!

8 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?

2 Likes

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!

It worked! No words to thank you for the tip.
Testing with a MySql database, I noticed that the changes made through PHPMyAdmin are reflected almost immediately in the repeater group. Did this happen because every second there is a query request to the database?

Hey @maze ,

We’re you able to find a workaround similar to this, but for the Stripe Marketplace Plugin? I’m having issues trying to figure it out. Seems impossible! Ha

1 Like

I am sorry I can’t help you with this issue…