I'm not sure what's the best way to handle async / await here, it doesn't seem like my application is waiting before it calls render so it's trying to load before the data is ready.
data.js:
this.asyncFunction = async (x) => { return await _makeRestcall(x) }
this.load = async function(id) {
this.data = {
params: await asyncFunction("restCall1").value.reduce( // transform data),
ideation: await asyncFunction("restCall2").value.reduce( // transform data),
roles: await asyncFunction("restCall3").value.reduce( // transform data),
serviceGroups: await asyncFunction("restCall4").value.reduce( // transform data),
allocationPercents: [],
maintenanceYears: [0, 3, 5]
};
return this.data;
};
async init() {
this.d = await this.load();
console.log("called data async");
}
app.js
import data from 'data'
await data.init();
render()
Ideally I'd like all the calls in data to run in parallel then return this.data when all the calls are done.