Api and local storage (client storage sync)

Hi, I am trying to copy the API database to the client database but cant seem to get it right.

I think I have not set the client database up correctly.

Please can you assist me in guiding me to correct this?

Please see screen shots below:




You need to make the schemas match exactly. So all property names and types have to be the same for both resources. Then you should be able to copy the API response to client side.

OK,

I have done the changes but I am still getting the same message:



According to your screenshots Productprice type doesn’t match. For the first one it’s number and for second numeric text. Try again after making those match.

1 Like

Thanks. Will try that and let you know

Hi,

I tried it but it doesn’t seem to want to work.

Please see screen shots below:

It keeps on saying the "list of objects with 5 properties is not assignable to list of objects with one property.

This is when I try and bind it to the output of the get collection node.

Could you tell me your app ID so I could take a look at your app? (If that sounds okay to you)

Hi Tomi,

No Problem, the app id is 99157.

Thank you

Hi Tomi,

Please let me know if you got a chance to look at the build?

Yes, I’ll let you know. I actually checked your app already yesterday and all looked good which made me think that there might be some regression bug that has come up in Composer at some point. I’ll put it on our backlog when if/when I can make simple repro for this. I’ll do that as soon as I have time.

In the mean while I think it might be possible to circumvent the issue by adding the Get record collection response into a Products Data variable and then use that variable when you use Replace client-side record collection. You might need to use Formulas to make this happen if direct binding complains that the “List isn’t assignable…”

Thanks Tomi. I will try that

Hi Tomi,

I have tried what you said but the list is still empty.

Please can you have a look and let me know if there is something I am doing incorrectly. ?

I used the formula option.

Please see screen shot

So the issue in this solution is that you’re working with a List, so you cannot specify each property one by one. That would work with an Object, but for List you need to define the Objects in it as a whole.

I think this could be done by binding the Assigned value of Set app variable or Records of Replace client-side record collection Flow functions to this Formula:

MAP(outputs["Get record collection"].records, MERGE([item, {id: GENERATE_UUID()}]))

It will MAP the Objects in the List one by one and MERGE will make the output List to have Objects that have all existing properties (item) and will add a id that’s newly generated.

Hopefully this will help you

1 Like

Hi Tomi,

I now get the list to pull over to client side storage but it only stays there for 3-5 seconds and disappears again.

The default logic for a Data variable polls the backend every five seconds and replaces the Data variable with the response. It sounds like this could cause your issue. You can read more about Data variables here: https://docs.appgyver.com/app-logic/data-variables

I saw a video, and they have a similar issue, so they delete the flow I mark in red. I hope it would help

1 Like

I just saw a related topic:

1 Like

Hi Tomi,

I am still stuck in finding a way to get the data from the API onto the local client storage.

I have gotten the record collection and assigned it to the data variables and then tried assigning the output of the data variables to replace client-side record collection but it doesn’t seem to work at all.

Please can you assist me in finding a workaround if possible.

Thank you for all your help so far.

Hi! Sorry for the delayed answer. From the screenshot you have it looks like your schemes don’t match. You can either:

  1. Fix the schema to match in the data
  2. Use a formula to bind this output instead, something like outputs.["Get record collection"].records

Hi Mevi,

thank you for the info. I have tried it but I am still getting stuck trying to sync 7000 records from API to local.

I have tried getting the record collection and replace client side database but that is giving an error.

I have also tried getting a single record and trying to loop it but I still get an error there as well.

Please let me know if I am missing something?

1 Like