title: firebase cloud functions invoke callback
body: <p>I'm using firebase admin SDK to create new User to my web app.</p>
  <pre><code>// function to create user and store additional info in firestore
  exports.createUser = functions
      .https.onCall((data, context) =&gt; {
        admin.auth().createUser({
          phoneNumber: data.phoneNumber,
          displayName: data.displayName,
        }).then((user) =&gt; {
          // store data in firestore
          admin.firestore().collection(&quot;user&quot;).doc(user.uid).set({...data});
        }).catch((err) =&gt; {
          // handle error
        });
      });
  </code></pre>
  <p>When I call the function from the client (attach it to onClick event) I want to wait till user is successfully added in firestore and invoke the fetchUser function so I can see the new list of data with the newly added user. Currently fetchUser gets called and page refreshes but I cannot see the newly added user before refreshing it.</p>
  <pre><code>const createUser = functions.httpsCallable('createUser');
  
  const createNewUser = () =&gt; {
      createUser({
        phoneNumber: &quot;+1111111111111&quot;,
        displayName: &quot;test&quot;,
        introduction: &quot;testcreate&quot;,
      })
    .then((res) =&gt; {
      fetchUser(); // fetchUser just fetches user data from firestore and rerenders page 
    })
    .catch((err) =&gt; {
      console.log(err);
    });
  </code></pre>
  <p>};</p>
  <p>To summarize, <strong>can I know when cloud function will complete its job and run a particular function or task ?</strong></p>