Await for a query to finish

Hey @George_B,

So what I meant was that instead of taking the data to map over from the queries response (.data), which I assume isn't available yet by runtime, you instead take the immediate success-callback response of the query.

I just setup a demo and it looks like you won't even need the async and could do something like:

let localUserID = 'XmMEhmVur9sX7tBDOrT7';
let results;

const orgs = await new Promise((resolve) => {
  GetOrgsOfUser.trigger({
    additionalScope: {
      userID : localUserID
    },
    onSuccess: (data) => {
      resolve(data);
    },
  });
});

orgs.map(row => {
  results = {
    name: row.displayName,
    photo: row.photoURL
	}
});

return results

Does that work for you?

3 Likes