Hello,
I have an external API and I want to show its data in a table as soon as a user enters the page.
What I did so far is:
create a database, each line contains a row on the table.
Most of the data is static, however some fields need to be retrieved from an external API,
So what I do is put under onReady() a loop that queries each item (it gets the end points from the database), and then it updates each field in the database with the current value.
Once the database is updated, its just connecting the table to the database to show new values.
I have a feeling this is not the best way to achieve this result.
Any suggestions?
Thanks!
Gal
Not quite sure what you mean, but if you try to retrieve data from every individual endpoint in your loop, you do create a lot of traffic.
Do all endpoint have the same URL, or are they different, just with other params?
If the same, have you considered looping, puting all the endpoints with params into an array, hand that to the (same) endpoint and return a result array?
The endpoint is the same, only one parameter is changing
I will try to send several params in a single query
I thought maybe there is an option to tell a field in the database to update automatically vs an external API every specific interval (this would make my life easy)
I am re-addressing this issue because it seems that when someone enters the page, the database updates, however the page is showing the data before the update. Can I force a dataset on a page to refresh?
Are you sure you have used both the $w.onReady (page level) and, inside, the dataset onready?