App continually making calls to API

When I test my app in the previewer, it continually calls the data sources from my REST API–multiple each second. It starts making calls once it has been on a page that uses that data source, and continues to call it even after I’ve left that page.

What can we do to stop the continual calls?

App #98690

Is it something with the data variable settings? By default when you create a new variable it will repeat calls after I believe a 2-second delay. Since it is connected to page mounted - it will do so, even if the page is not focused.

Good point, @Greg_F. I’ll play around with the delay and report back on the results. Thanks!

@Greg_F, you were right. The “Get record collection” nodes were set to refresh every half second even if they had been successful. I was able to change it to get the behavior I needed. Thanks again!

Ciao Erin,
did you figure out how to change the refresh settings? Even if I change the mounted page with other events or even if I cut completely the link the refresh happens every 10 seconds.
Where have I to make this change?
Thanks

Hi @Munus!

In my case, I fixed it by going to the logic on the data variable. By default, the logic looks like this:

So on every data variable on the page, I had to delete the connections that created the reload loop. After it looked like this, it stopped hitting the server except when I told it to:

I also went through the rest of the logic on the page to ensure I didn’t have any loops hidden anywhere else. I haven’t seen your page, so I couldn’t say exactly where to look, but I hope you’re able to find it!

1 Like

Erin you enlighten me !!! I was just checking a data variable in one page and i have forgotten to have another data variable in another page with the same data source!
Many thanks for your time and for the tip

1 Like

So just curious, what if you add a new object to the database? How does it know to update the view?

Good question: I did the tests, as I also had that doubt. When doing Erin_Wagner’s steps the following happens:

1). When making changes from your API, the application is updated only if the client or user closes the app and reopens it, all the changes you make to the API to provide its content will be reflected.

2). If it is updated instantly if it is the WEB, when you enter a menu and you return to the beginning, if the instant change is reflected only if you go from one page to another.

3). In mobile application when opening, the customer or user will notice instantly that there was a change, but if you move from one section to another and at that time the owner of the API made a change, that change will not be reflected, until the user or customer closes the app and reopen it.

Conclusion:

If you have a REST API that you must offer online content such as stock market, weather, instant news, etc … it is not advisable to remove that section.

But if it is for a store, some blog, documentary, news of the day, etc… if it is good not to have it so that it is not hitting the API and calling every second.

The other is to expand the time to a good few minutes in case you don’t want to remove it, you put it in minutes and give it the desired value.