Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Tutorial on saving DB array to local storage and vice versa

Hello Anil,

Variable data is available for absolutely all the services

Anil Sagar
Posts: 0
Joined: Fri Jul 04, 2014 1:13 pm

Tutorial on saving DB array to local storage and vice versa

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.

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Tutorial on saving DB array to local storage and vice versa

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

Anil Sagar
Posts: 0
Joined: Fri Jul 04, 2014 1:13 pm

Tutorial on saving DB array to local storage and vice versa

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.

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

Tutorial on saving DB array to local storage and vice versa

Hi Anil,

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

Anil Sagar
Posts: 0
Joined: Fri Jul 04, 2014 1:13 pm

Tutorial on saving DB array to local storage and vice versa

Yes this works. Thanks

Return to “Issues”