Page 1 of 1

Use array response from an external API in Javascript

Posted: Thu Dec 05, 2013 11:20 am
by Andrew Walker

I am sure this is easy, but I have been unable to find a way, to use the REST to collect a json data set, which is returned into an array. The array has about 4 - 8 items, but I only need 2. So I want to go through each item and collect only the items with a certain type.

I can get the data set, but how I do I then run a script, using what came back in the response. Due to it being an array, I am unable to set a local storage. How do I access it in javascript ?

Hope that makes sense. Thank you


Use array response from an external API in Javascript

Posted: Thu Dec 05, 2013 12:18 pm
by Maryna Brodina

Hello! On service success event you'll get entire response in data variable.


Use array response from an external API in Javascript

Posted: Thu Dec 05, 2013 12:39 pm
by Andrew Walker

Yea, I can see that, the array is called 'areas'. But I am unable to use it in Javascript. How I do access it in Javascript ?


Use array response from an external API in Javascript

Posted: Thu Dec 05, 2013 2:43 pm
by Maryna Brodina

On service success event all data is returned to 'data' variable. Use this 'data' variable, not 'areas'.


Use array response from an external API in Javascript

Posted: Thu Dec 05, 2013 3:30 pm
by Andrew Walker

Thank you