In my code, I have a variable that combines multiple promises using async/await and concatenates them into a single object
const traversals = (await traverseSchemas({filename:"my-validation-schema.json"}).concat([
_.zipObject(
["id-1", "id-2"],
[
await loadSchema({
filename: "schema-1.json"
}),
await loadSchema({
filename: "schema-2.json"
}),
]
),
]);
The traverseSchemas
function returns an array object like this:
[{"key1":{object}}, {"key2": {object}}]
I am currently looking into whether there is a way to apply the await keyword only at the traversals
level so that all promised data gets fulfilled, or if there is a better way to refactor this code.