Skip to content

Instantly share code, notes, and snippets.

@thakursaurabh1998
Created December 28, 2018 13:16
Show Gist options
  • Save thakursaurabh1998/357c7890c3480e8012ae3f688ebd46ad to your computer and use it in GitHub Desktop.
Save thakursaurabh1998/357c7890c3480e8012ae3f688ebd46ad to your computer and use it in GitHub Desktop.
Use of promise for async requests in an array
async function LoadDefects(projectId) {
const res = await restApi.query({
type: "defects",
scope: {
workspace: "/workspace/275276784308",
project: "/project/" + projectId
}
});
let table = "<table>";
await Promise.all(
res.Results.map(async defect => {
// readDefect is another Async function which returns a string
table += await readDefect(defect);
})
);
table += "</table>";
return table;
}
LoadDefects(275276784740).then(res => {
a = res;
console.log(a);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment