1. Home
  2. Documentation
  3. Using Dropsource
  4. Connecting to an API
  5. Receiving Responses

Receiving Responses

Each API request in your app can include response fields along with each status code it returns. Typically you will use fields from the 200: OK response – you can display the values in your page Elements or use them elsewhere in the app. If your response includes arrays, you can bind them to dynamic Elements.

With an request open in the API tab, the Responses section lists all fields returned. Select a status code from the drop-down list (if your request returns more than one).

api response fields

Fields may be nested inside objects and arrays.

Click a response field and select an Element to display it in – you can alternatively click and drag onto the Canvas if the Element is visible there.

response element

ⓘ Note

Dropsource will only allow you to bind to valid Elements for the data type of the field, so text items can only be displayed in Elements that display text, and so on.

Once an Element is bound, you will see a green dot next to it.

places bound

Actions added to API request events can also access response fields.

ⓘ Note

To display an image from a URL in a response, add an Action to an API Event or an Element loaded Event.

Displaying Array Data

Any arrays in your API response will be listed in Dropsource as Data Sources. To display the fields in a Data Source:

ⓘ Note

Your app can detect and respond to the array data loading into each repeating child Element or can iterate through array entries when a response is received. This allows you carry out any processing you need on the data. See API Events for more detail.

Using Array Data

When you have a Data Source bound to a dynamic Element, your app can access fields from the Data Source in Actions for Events on the dynamic Element’s child views.

data source action

For example, if you add an Action to the Tapped Event of a Table Cell, the Action can access the fields for the array entry being displayed inside it. Similarly, if you run another request when an Event occurs on a dynamic child Element, you can pass response fields from the first request as parameters to the second one.

ⓘ Note

In the Checklist example app – in the landing page, select List Cell / Tile in the Element Tree. Open Properties > Events and add an Action to the Tapped Event. Select the Go To Page Action to see its detail – it uses the Data Source Context. The Action is able to access the ID for the tapped item because the Data Source is bound to the parent Table Element.

Was this article helpful to you? Yes No

How can we help?