Chaiwa

getData

Jan 15th, 2021
672
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * A generic helper method for getting data of any kind from DHIS2.
  3.  * - This can be used to get `DataValueSets`,`events`,`trackedEntityInstances`,`etc.`
  4.  * @public
  5.  * @function
  6.  * @param {string} resourceType - The type of resource to get(use its `plural` name). E.g. `dataElements`, `trackedEntityInstances`,`organisationUnits`, etc.
  7.  * @param {object} [params] - Optional `query parameters` e.g. `{ou: 'DiszpKrYNg8'}`. Run `discover` or see {@link https://docs.dhis2.org/2.34/en/dhis2_developer_manual/web-api.html DHIS2 docs} for more details on which params to use for a given type of resource.
  8.  * @param {{apiVersion: number,operationName: string,responseType: string}}[options] - `Optional` options for `getData` operation. Defaults to `{operationName: 'getData', apiVersion: state.configuration.apiVersion, responseType: 'json'}`.
  9.  * @param {requestCallback} [callback]  - Optional callback to handle the response
  10.  * @returns {Promise<state>} state
  11.  * @example <caption>Example getting one `trackedEntityInstance` with `Id` 'dNpxRu1mWG5' for a given `orgUnit(DiszpKrYNg8)`</caption>
  12.  *  getData('trackedEntityInstances', {
  13.  *    fields: '*',
  14.  *    ou: 'DiszpKrYNg8',
  15.  *    entityType: 'nEenWmSyUEp',
  16.  *    trackedEntityInstance: 'dNpxRu1mWG5',
  17.  *  })
  18.  *
  19.  */
RAW Paste Data