I have the following simplified functions:
create: async (x) => {
...
id = await functionX(); //among the other it stores url in DB
const2 = await functionY(id); //this function was built to retrieve value from DB stored by functionX using id.
return const2;
}
functionY (id) {
const query = data.base.get(id)
return query.url
}
Unfortunately, id resolves before storing to DB and therefore query.url
becomes undefined.
I was looking for something simple like:
const2 = await (functionY(id)) ? functionY(id) : null
I know it's wrong, but anyways, how do I deal with such cases?