API Connector only works sometimes

I am new to the bubble platform but I do have experience coding and working with API’s. I signed up with a personal account to do some testing to see if this system is right for a project I am working on. I need to access data in an external database, but cant do this through the SQL connector because I do not have the IP address that bubble uses since they use a range. This causes an issue getting through the firewall. I know there somewhat workarounds for this but I would have to change hosts.

My solution was to create an API on my hosting side that would allow my bubble app to pull data out of the database through the API Connector plugin. I setup a test API that pulls data out of a test myql I setup to test this theory before proceeding. Here is the basic API I setup to pull the data out of the database on my hosting.

https://kgcadmin.com/rest-api/items/read.php

If you go to that link you will see the json that is returned.

I setup my API Connector like this.

Initialization worked. I then setup a repeating group on my bubble app like this.

Inside of the repeating group I added a textbox that I setup like this.

The issue I am having is when I load my bubble app it only works sometimes. About 1 out of every 10 refreshes of the page actually loads the data. What could possibly be the issue? I know my api on my side returns the data 100% of the time if you go to the page https://kgcadmin.com/rest-api/items/read.php

So why would the API connector only be fetching that data sometimes and not 100% of the time. Any help would be greatly appreciated. Thank you in advance.

So does the data change while the bubble page is open and fully loaded? Is the issue that the updated data does not refresh? Bubble would load the data once when the page loads. To get it to refresh, the API call would have to had changed. You could try adding a parameter to the API call. Call it refresh and make it a number or text field. When you wish to refresh the data, just change the value of the refresh parameter and this will force Bubble to get a new set of data.

The data only needs to load once, when the bubble page initially loads. The issue is 9 out of 10 times nothing loads. If I refresh my bubble page 10 times I can usually get the api data to load about once. I provided the links in my post so that anyone who wanted to try it could see. I know it can be kinds hard to explain exactly what’s going on and its better to see it.

Sorry, for my misunderstanding. This threw me: The issue I am having is when I load my bubble app it only works sometimes. About 1 out of every refreshes of the page actually loads the data.

Whoops, that is confusing. I meant to say 1 out of every 10 refreshes. I should have proof read.

No worries. I tried running this in my API connector in my app, but it times out when initializing. So something about the API response seems to be an issue. It does not even initialize

Yeah, I had the same issue but after trying to initialize it multiple times it finally did. Is there something about the Json format that is not correct I don’t understand why it would have trouble initializing sometimes and then initialize finally as it’s acting the same way when I use it on my page sometimes it loads and sometimes it does not. I’m just not sure what exactly the issue is to fix. If it didn’t work at all that would be one thing but it works sometimes and then sometimes it does not.

Sorry, I am not an expert in JSon setup, but if I were you, I’d be fiddling there to try and fix it. Maybe simplify it first and then steadily build it out until it errors, or not.