Skip to content

Instantly share code, notes, and snippets.

@TobyEalden
Last active October 20, 2016 10:29
Show Gist options
  • Save TobyEalden/18f0a3d48495c720d87b4624942192f6 to your computer and use it in GitHub Desktop.
Save TobyEalden/18f0a3d48495c720d87b4624942192f6 to your computer and use it in GitHub Desktop.
parseXmlStringAsync(response.text)
.then((result) => {
var entryList = [];
_.forEach(result.feed.datastream, (val) => {
if (idList.indexOf(Number(val['$']['id'])) > -1) {
var entry = {
'ID': Number(val['$']['id']),
'timestamp': Number(new Date(val.current_time[0]).getTime()),
'currentvalue': Number(val.current_value[0]),
'maxvalue': Number(val.max_value[0])
};
entryList.push(entry);
}
});
return tdxApi.addDatasetDataAsync(packageParams.parkDataTable, entryList)
})
.then(() => {
// If we get here, there were no errors.
output.debug("Added data to the dataset");
return ({error: false});
})
.catch((err) => {
// Catch any errors here, report them, then continue.
output.error("Failure processing entries: %s", err.message);
return ({error: true});
})
.then((resArr) => {
return cb(resArr);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment