Working on API response that gets user data from 10K ft system via API. The response looks like:
"data": [{
"id": 30000,
"display_name": "John Doe",
"email": "[email protected]",
},
I want to save this data in three different arrays for each response to be used later for looping through user id. I am not sure how to go about it. Below is the code I have worked on so far. I will appreciate any help here. Thanks
function getUsers() {
var auth = 'authentication'
var url = 'https://api.10000ft.com/api/v1/users?' + '&auth=' + auth;
var options = {
method: 'get',
headers: {
Authorization: 'Bearer ' + auth
}
};
};
let response = UrlFetchApp.fetch(url, options);
let json = JSON.parse(response);
};
var response = UrlFetchApp.fetch(url, options);
var json = JSON.parse(response);
var ids = [];
var display_names = [];
var emails = [];
function result(data) {
data.forEach(element => {
ids.push(element.id);
display_names.push(element.display_name);
emails.push(element.email);
});
return { "ids": ids, "display-names": display_names, "emails": emails };
}
console.log(result(data));