Created
March 17, 2020 15:03
-
-
Save chathurawidanage/5058fb41a552ba5a8847f8de11e53af0 to your computer and use it in GitHub Desktop.
TEI fetch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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