Created
December 28, 2018 13:16
-
-
Save thakursaurabh1998/357c7890c3480e8012ae3f688ebd46ad to your computer and use it in GitHub Desktop.
Use of promise for async requests in an array
This file contains 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
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