Matt6097125
Posts: 0
Joined: Tue Jul 30, 2013 6:56 pm

Mapping JSON from local storage to repeater field

Hi there -

I'm trying to figure out how to do my first REST call. I currently have a page where you can query a remote REST and the results are returned in a JSON array. I want to display these results via a dynamic list on a new page. From what I've found in the documentation it sounds like I should store the result JSON to local storage and then load it up on the new page. I've done so using javascript, but I'm not sure how to pull that json array back out of local storage on the new page so I can map the array to a repeating field. Should I be creating a new service to parse the locally saved JSON for mapping?

Thanks for the help.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Mapping JSON from local storage to repeater field

Why not just map the result directly to a List component?

Matt6097125
Posts: 0
Joined: Tue Jul 30, 2013 6:56 pm

Mapping JSON from local storage to repeater field

Sorry, this is my first time using your program and I guess that's what I'm trying to figure out. :)

So, I have two pages. On page A, I capture fields that are for querying (like looking for a name). On page A when you click on a "Search" button, it calls the REST and gets the results returned in a JSON array that is an array of objects with a couple of fields. Then on completion of that request, I save the JSON array to local storage and load up page B.

This is where I'm getting lost. On page B, I need to pull that json array of objects from local storage and then map the object's fields to labels within a list item.

For example, lest say I get a JSON array from my query that has 3 events and each event has a name and date field. I need to display 3 list items - each with the name and date mapped to labels for that list item. It looks like I can take my local variable and map it to the list, but I can't figure out how to break out my local variables' objects and map the name to the name label for that list item.

I thought about just calling the REST query when I first load up page B and then I can map those results to the fields. That works, but it doesn't look as nice because I don't get a "loading" icon when the page first loads and is querying the service (it just looks like the page has hung).

Am I going about this wrong?

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Mapping JSON from local storage to repeater field

If you want to use the mapping feature on page B, one option is to create a Generic Service that would read the data from local storage. The loaded data can then be mapped, as using a regular (REST) service.

https://getsatisfaction.com/apperyio/...

Return to “Issues”