So i have 2 collections

1 collection is 'users'. There i have documents (objects) with property 'profile', that contains string. It's id of profile, that is stored in other collection 'roles' as document.

So i'm trying to get this data, but without success. Is there exist join method or something like that? Or i must use promise for getting data from collection roles, and then assign it with agent?

async componentDidMount() {
      .onSnapshot(async snapshot => {
        let changes = snapshot.docChanges()

        const agents = this.state.agents
        for (const change of changes) {
          if (change.type === 'added') {
            const agent = {

            await firebase
              .doc( response => {
                //when i get response i want to set for my object from above this val 
                agent['profile'] =
                //after that i want to push my 'agent' object to array of 'agents'

          isLoading: false,
          agents: agents

1 Answers

vishnu prasath On

To do async operation on array of objects you can use promise.all, i have given a example below that is similar to your use case where multiple async operation has to be done

  const all_past_deals = await Promise.all( (item, index) => {
     const user = await Users.get_user_info(item.uid);

    const dealDetails = await Deals.get_deal_by_ids(user.accepted_requests || []);

    const test = await Users.get_user_info(dealDetails[0].uid);
return test


This way you can get data from once api call and make other api call with the obtained data