Jerry Benzie
Posts: 0
Joined: Wed Sep 10, 2014 3:54 pm

Create a list based on localStorage array

Thank you for the fast response. The link you've provided seems to be for using echo to test a service. The echo would return static data that I would enter into the form. Is it possible to use the echo with dynamic data? Can I return an array via echo?

Jerry

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

Create a list based on localStorage array

Hi Jerry,

Here is a sample echo that returns an array:pre[
{ "txt":1, "val":0 }
,
{ "txt":2, "val":1 }
,
{ "txt":3, "val":2 }
,
{ "txt":4, "val":3 }
,
{ "txt":5, "val":4 }
,
{ "txt":6, "val":5 }
,
{ "txt":7, "val":6 }
,
{ "txt":8, "val":7 }
]/pre

Jerry Benzie
Posts: 0
Joined: Wed Sep 10, 2014 3:54 pm

Create a list based on localStorage array

Yes, but that isn't dynamic. The array I want to return is a list of contacts that the user will maintain within the app. So the size of the app will vary for each user. I want to store contactName and contactPhone in array contactList using localStorage then display each object in this array for the user to see. Therefore, I can't use static data.

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

Create a list based on localStorage array

Hi Jerry,

As we used to say, you set echo with dynamic data: pregetContacts.__requestOptions.echo = '[{"phone":"123", "name":"abc"}]';/pre
After echo is set, you should call execute from instance of the service. A common example of echo substitution and instance call is here:
Image

prerestservice2.execute();/pre

Jerry Benzie
Posts: 0
Joined: Wed Sep 10, 2014 3:54 pm

Create a list based on localStorage array

I may not fully understand what you're telling me to do, but when I set the echo to "getContacts._requestOptions.echo = '[{"name":"abc", "phone":"123"}]'; I get "abc" as the name of the contact when I run the app in an Android emulator. I can't hard code the values for "name" and "phone", this data should be dynamic based on the contacts stored on the user's native device. Also, regardless of how many times I called the getContacts service, only one object (contact) appeared in the list. This needs to return an array.

I apologize for being so difficult.

Thank you for your help and time,
Jerry

Jerry Benzie
Posts: 0
Joined: Wed Sep 10, 2014 3:54 pm

Create a list based on localStorage array

Is there any way you could look at my project and give me advice based on what you see?

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

Create a list based on localStorage array

Hi Jerry,

Please replace this part of example code'[{"name":"abc", "phone":"123"}]'/code with the data received from local storage.

If you have some problems with it please share your app with a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a and tell us its name and steps to map this response.

Jerry Benzie
Posts: 0
Joined: Wed Sep 10, 2014 3:54 pm

Create a list based on localStorage array

Thank you. The project has been shared with Appery.io support. The name is "Check In" and I'm having trouble specifically with the "contacts" page. When you click "import contacts" the user's contacts from the native device are displayed in the upper list. This part works fine. When a contact is selected, I want the person's name and phone number to be stored in localStorage in an array, then displayed in a second list (the lower list under "Contacts"). This is what I'm having trouble with.

Jerry

Jerry Benzie
Posts: 0
Joined: Wed Sep 10, 2014 3:54 pm

Create a list based on localStorage array

How do I add a dynamic variable to the echo response? If I don't use the format in your example above, I get a parsing error. I don't know how to replace the static data in '[{"name":"abc", "phone":"123"}]' with data received from local storage.

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

Create a list based on localStorage array

Hello Jerry,

You have a service call to save the data in local storage when you click on the contacts, but instead of service you need to call js code that will check the saved contacts and add a new one if this contact is not already there. Please correct this and contact us then.

Return to “Issues”