-
-
Save myndzi/a99efe6a5c2b47c9d256b31932802a04 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var queue = [], | |
output = []; | |
function add(args) { | |
queue.push(args); | |
} | |
function delay(n) { | |
return new Promise(function (resolve) { | |
setTimeout(resolve, n); | |
}); | |
} | |
function process() { | |
if (queue.length === 0) { return; } | |
return callAc(queue.pop(), [ | |
'FormattedID', | |
'Name', | |
'Children', | |
'Parent', | |
'TeamMembers' | |
]).then(function (result) { | |
result.Object.Results.forEach(function (item) { | |
output.push(item.Name); | |
queue = queue.concat(item.Children._ref.split('webservice/v2.0')[1]); | |
}); | |
return delay(1); | |
}).then(process); | |
} | |
function callAc(ref, parameters) { | |
return restApi.get({ | |
ref: ref, | |
fetch: parameters, | |
scope: { | |
workspace: '/workspace/XXXX' | |
}, | |
requestOptions: {} | |
}); | |
} | |
add('/Project/<some_project_id>/Children'); | |
process().then(function () { | |
console.log(output); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
awesome..