Adeeb Shanaa
Posts: 0
Joined: Wed Jan 22, 2014 5:53 am

Query list into an local storage array

Hello,
I'm trying to query a list of phone numbers from a collection and then store them into a local storage array for use by another javascript module.

I've created a data service as shown in the image. Image

I'm not sure if I've got that defined correctly with the mapping.

I'm then trying to add javascript in the "phoneNoArray" local storage variable to see the returned results, iterating through the array, but don't seem to be able to accomplish that. Ideally I want to set it up as I can access the array results from other javascript modules in the application.

Any assistance would be much appreciated. Please note that I am not very JS literate, so apologies in advance for my ignorance.

Thanks,
Adeeb

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Query list into an local storage array

Hi Adeeb,

It's better to check what value you are storing in localStorage variable - you can see it using DevTools in the browser (F12) in the Resources tab:
:: http://docs.appery.io/documentation/d...

Adeeb Shanaa
Posts: 0
Joined: Wed Jan 22, 2014 5:53 am

Query list into an local storage array

phoneNoArray only shows a single numeric value in the Resources console, not an array. Am I defining the data source mapping incorrectly? Please advise.

Thanks,
Adeeb

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Query list into an local storage array

Hi Adeeb,

Run this code on service Success event:prelocalStorage.setItem("pnoneNoArray", JSON.stringify(data)); /preAnd remove your mapping please.

Adeeb Shanaa
Posts: 0
Joined: Wed Jan 22, 2014 5:53 am

Query list into an local storage array

Thank you Katya, that worked! I really appreciate the help.

Return to “Issues”