Skip to content

Instantly share code, notes, and snippets.

@simsong
Last active Nov 25, 2019
Embed
What would you like to do?
promise example
function getDataFromAPI(data, options) {
fetch("/app/get_stats")
.then(function (response) {
return response.json();
})
.then(function (result) {
var sysload_dict = result.sysload;
Object.keys(sysload_dict).forEach(function (key) {
data.addRow([key,
sysload_dict[key]['freeGB'],
sysload_dict[key]['min1'],
sysload_dict[key]['min5'],
sysload_dict[key]['min15']
])
});
drawTable(data, options);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment