Refresh database after calling API

  

Hi

I've been struggling for a while trying to solve this problem that ive got

So basically after calling an API I've been trying to refresh the data again using the LayoutOnPullToRefresh action. Is there a way to get the updated data from the API and then storing it into the database when user tries to refresh?


Thanks

Solution

Storm Kippie wrote:

Hi

I've been struggling for a while trying to solve this problem that ive got

So basically after calling an API I've been trying to refresh the data again using the LayoutOnPullToRefresh action. Is there a way to get the updated data from the API and then storing it into the database when user tries to refresh?


Thanks

Hi,

Do follow the below steps for the REST API:

1- Create REST API & create it's appropriate requires Entities in Local Storage from Structure.

2- Create a Data Action on Screen where you want to call the REST API

3- Add an aggregate for the Local Entity to the Screen.

4- The DataAction gives you onAfteFetch Event, where you have to define an action.

5*- In the action clear the  Local Entity by calling DeleteAll()

5.1- Validate your REST API result & then Dump it accordingly using ListAppend or List with CreateorUpdateAll() / CreateorUpdate()

5.2- Refresh the Aggregates 


Note: You can use the DataAction i.e you can call the DataAction Refersh on LayoutOnPullToRefresh Action.

Cheers.


Assif

Solution

Hi Storm,

Did your problem is resolved or not?


Thanks,

Rajat Agrawal