Skip to content

Studio Script Reference: Data actions

These are the low level functions used by the trigger actions in the Data panel. They generally require the ID of the data source you want to trigger a request from. That can be found under the Advanced section of the inspector panel when you have the data source selected.

Headers, params and body data from your data source is included automatically any time you make a request, including computed properties and any header/param fields using data overrides.

context.actions.loadData()

Programmatically triggers a GET API data source. Corresponds to the Data -> Load data trigger action.

Example

js
context.actions.loadData({
  target: 'dc61dc36-b0f4-4dc9-a9a8-7f4ec0088ac7'
});

Optionally, you can include body data for the request. Remember that you can also add computed properties to the Body group in the data source configuration, instead of including it here:

js
context.actions.loadData({
  target: 'dc61dc36-b0f4-4dc9-a9a8-7f4ec0088ac7',
  data: {
    username: 'michael123',
  }
});

context.actions.postData()

Programmatically triggers a POST API data source. Corresponds to the Data -> Post data trigger action.

Example

js
context.actions.postData({
  target: 'dc61dc36-b0f4-4dc9-a9a8-7f4ec0088ac7'
});

Optionally, you can include body data for the request. Remember that you can also add computed properties to the Body group in the data source configuration, instead of including it here:

js
context.actions.postData({
  target: 'dc61dc36-b0f4-4dc9-a9a8-7f4ec0088ac7',
  data: {
    username: 'michael123',
  }
});

context.actions.putData()

Programmatically triggers a PUT API data source. Corresponds to the Data -> Put data trigger action.

Example

js
context.actions.putData({
  target: 'dc61dc36-b0f4-4dc9-a9a8-7f4ec0088ac7'
});

Optionally, you can include body data for the request. Remember that you can also add computed properties to the Body group in the data source configuration, instead of including it here:

js
context.actions.putData({
  target: 'dc61dc36-b0f4-4dc9-a9a8-7f4ec0088ac7',
  data: {
    username: 'michael123',
  }
});

context.actions.deleteData()

Programmatically triggers a DELETE API data source. Corresponds to the Data -> Delete data trigger action.

Example

js
context.actions.postData({
  target: 'dc61dc36-b0f4-4dc9-a9a8-7f4ec0088ac7'
});

Optionally, you can include body data for the request. Remember that you can also add computed properties to the Body group in the data source configuration, instead of including it here:

js
context.actions.postData({
  target: 'dc61dc36-b0f4-4dc9-a9a8-7f4ec0088ac7',
  data: {
    username: 'michael123',
  }
});

context.actions.setData()

Write data to a data source. This is the same as setting data via context.sources.MySource.myProp = 123;, so you should never need to use setData() programmatically in practice.

Example:

js
context.actions.setData({
  target: 'dc61dc36-b0f4-4dc9-a9a8-7f4ec0088ac7',
  data: {
    myProp: 123
  }
});

context.actions.resetData()

Reset the response data of an API source. It can also be used to clear the results and answers of a Response source, although for that case you usually want resetResponses() (see below).

Example:

js
context.actions.resetData({
  target: 'dc61dc36-b0f4-4dc9-a9a8-7f4ec0088ac7',
});

context.actions.resetResponses()

Reset the results and answers of a Response source. This is similar to resetData(), except it also kills any upcoming calls to fetch updated results.

Example:

js
context.actions.resetResponses({
  target: 'dc61dc36-b0f4-4dc9-a9a8-7f4ec0088ac7',
});

context.actions.submitResponse()

Submits a response for a Response source. With this action, you also need to include a value. This value should be a number that corresponds to an index in the associated Ease Live event's array of options.

Example:

Given an event with an options payload like:

js
[
  {
    name: 'Steph Curry',
    number: 30
  },
  {
    name: 'Klay Thompson',
    number: 11
  },
  {
    name: 'Chris Paul',
    number: 3,
  }
]

To submit a vote for Klay Thompson, you would submit:

js
context.actions.submitResponse({
  target: 'dc61dc36-b0f4-4dc9-a9a8-7f4ec0088ac7',
  data: {
    value: 1
  }
});

context.actions.getResponseResults()

Refreshes the results data of a Response source.

Example:

js
context.actions.getResponseResults({
  target: 'dc61dc36-b0f4-4dc9-a9a8-7f4ec0088ac7'
});