Currently I am trying to call multiple awaits within a for loop, as per the documentation this is a performance heavy, so I was thinking of using promise.all()
but the problem I am facing is I need the first awaits data to call the other awaits values with in the for loop and assign the new values in an empty object that I created outside the for loop. Do you know how to use promise.all() to solve this problem?
This is my current code:
const parsedSchema = {}
const arrayOfValues = Object.keys(objectOfValues);
for (let i = 0; i < arrayOfValues.length; i++) {
const arrayOfValuesSchema = (
await getObjectFromExternalAPI(arrayOfValues[i])
).data;
Object.assign(parsedSchema, {
...(await $RefParser.dereference(JSON.parse(arrayOfValuesSchema.toString('utf-8')))).properties
});
}
Update: https://jsfiddle.net/sy4j6mgu/ this worked for me but I don't know how to simplify from here.