Page 2 of 2

Tutorial on saving DB array to local storage and vice versa

Posted: Fri Jul 25, 2014 3:26 pm
by Evgene Karachevtsev

Hello Anil,

Variable data is available for absolutely all the services


Tutorial on saving DB array to local storage and vice versa

Posted: Wed Jul 30, 2014 5:36 pm
by Anil Sagar

Hi Evgene, variable "data" is not working for me in a query service. It returns "undefined" on using the following code on success of query service:

localStorage.setItem("Offers_LS", JSON.stringify(data.Offer));

Same code works absolutely fine in case of a read service.

Both services are displaying the same data on my page though.


Tutorial on saving DB array to local storage and vice versa

Posted: Thu Jul 31, 2014 11:28 am
by Evgene Karachevtsev

Anil,

Entry data.Offer assumes that in response there is one object and it has the parameter Offer
You should output all variable data to the console and check this
preconsole.log(data);/pre


Tutorial on saving DB array to local storage and vice versa

Posted: Thu Jul 31, 2014 11:58 am
by Anil Sagar

Hi Evgene, console shows as follows but alert says undefined on using alert(JSON.stringify(data.Offer));

Image

Also, local storage also shows undefined for Offers_LS.

Image

Mapping is exactly the same for read service which fills Offers_LS absolutely fine.


Tutorial on saving DB array to local storage and vice versa

Posted: Thu Jul 31, 2014 8:36 pm
by Kateryna Grynko

Hi Anil,

Try the following code please:prelocalStorage.setItem("Offers_LS", JSON.stringify(data[0].Offer));/pre


Tutorial on saving DB array to local storage and vice versa

Posted: Thu Jul 31, 2014 11:31 pm
by Anil Sagar

Yes this works. Thanks