JSFiddle - React, Tailwind, and code Playground
JavaScript
const parsedSchema = {}
const arrayOfValues = Object.keys(objectOfValues);
const firstPromises = []
for (let i = 0; i < arrayOfValues.length; i++) {
firstPromises.push(getObjectFromExternalAPI(arrayOfValues[i]))
}
const firstPromisesData = await Promise.allSettled(firstPromises).then(data => {
return data.map((v) => { return v.value})
})
const secondPromises = []
for (let i = 0; i < firstPromisesData.length; i++) {
secondPromises.push($RefParser.dereference(JSON.parse(firstPromisesData[i].toString('utf-8'))))
}
await Promise.allSettled(secondPromises).then(data => {
for (let i = 0; i < data.length; i++) {
Object.assign(parsedSchema, data[i].value)
}
})