Skip to content

Instantly share code, notes, and snippets.

@chathurawidanage
Created March 17, 2020 15:03
Show Gist options
  • Save chathurawidanage/5058fb41a552ba5a8847f8de11e53af0 to your computer and use it in GitHub Desktop.
Save chathurawidanage/5058fb41a552ba5a8847f8de11e53af0 to your computer and use it in GitHub Desktop.
TEI fetch
const axios = require('axios');
const headers = {Authorization: "Basic YWRtaW46ZGlzdHJpY3Q="};
const baseURL = "https://play.dhis2.org/2.33.2/api/";
function getTEIs() {
return axios.get(baseURL + "trackedEntityInstances.json?ouMode=ACCESSIBLE&fields=[trackedEntityInstance,relationships]", {headers});
}
function getTEIInfo(teiId) {
return axios.get(baseURL + "trackedEntityInstances/" + teiId + ".json", {headers});
}
getTEIs().then(data => {
console.log(JSON.stringify(data.data));
});
getTEIInfo("ouQgthfDfU1").then(data => {
console.log(data.data);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment