Hello OpenFN Community,
I need to integrate two DHIS2 instances. This is, pull aggregate data from one instance and push it to the next.
Iโm fiddling with the HTTP adaptor. When I query the API I get this:
dataSet": "bkBzJ3ETIBD",
"period": "202111",
"orgUnit": "hfal93WttYV",
"dataValues": [
{
"dataElement": "XatzAFRX2pJ",
"period": "202111",
"orgUnit": "hfal93WttYV",
"categoryOptionCombo": "L1C8I3eiLDX",
"attributeOptionCombo": "qZPpgD4Ykqh",
"value": "0",
"storedBy": "usernameremoved",
"created": "2021-12-03T16:38:17.963+0000",
"lastUpdated": "2021-12-03T16:38:17.963+0000",
"followup": false
}
I built my get function like so:
get("http://DHIS2-URL/api/dataValueSets", {
query: {
dataSet: "bkBzJ3ETIBD",
orgUnit: "hfal93WttYV",
period: "202111",
children: "true"
},
headers: {"content-type": "application/json"}
},
function(state) {
console.log("-------------debugging-------------");
console.table("data values are: " + state.data.dataValues.value);
console.log("-------------debugging-------------");
return state;
}
);
I thought by doing the above iโd get an array of data values but i got this:
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ โฒ โฑ @openfn/core#v1.4.5 (Node.js v14.18.2) โ
โ โณ โฐ @openfn/language-http@3.1.11 โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
GET request succeeded with 200 โ
-------------debugging-------------
data values are: undefined
-------------debugging-------------
Finished.
and when i console.log(state)
i get this:
data: {
dataSet: 'bkBzJ3ETIBD',
period: '202111',
orgUnit: 'hfal93WttYV',
dataValues: [
[Object], [Object], [Object], [Object], [Object], [Object],
[Object], [Object], [Object], [Object], [Object], [Object],
[Object], [Object], [Object], [Object], [Object], [Object],
[Object], ... 159 more items
]
So my question is, how do I see the returned data values. My inbox is also empty.
Thanks