Page 1 of 1

Query list into an local storage array

Posted: Wed Jan 29, 2014 10:59 pm
by Adeeb Shanaa

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


Query list into an local storage array

Posted: Wed Jan 29, 2014 11:30 pm
by Illya Stepanov

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...


Query list into an local storage array

Posted: Wed Jan 29, 2014 11:38 pm
by Adeeb Shanaa

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


Query list into an local storage array

Posted: Thu Jan 30, 2014 4:38 pm
by Kateryna Grynko

Hi Adeeb,

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


Query list into an local storage array

Posted: Fri Jan 31, 2014 2:51 am
by Adeeb Shanaa

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