title: Convert A Firebase Method To Async Await
body: <p>I have this firebase method that creates a firebase user using a email and password</p>
  
  <pre><code>async register(name, email, password,type) {
      let id;
      const createUser = this.functions.httpsCallable('createUser');
  
      return await this.auth.createUserWithEmailAndPassword({email,password })
        .then((newUser)=&gt;{
          id = newUser.user.uid;
          newUser.user.updateProfile({
            displayName: name
          })
        })
        .then(()=&gt;{
          createUser({
            id:id,
            name:name,
            email:email,
            type:type
          })
        })
    }
  </code></pre>
  
  <p>It also adds the user to a firestore collection using a cloud function that takes the user details and user type.</p>
  
  <p>I have 3 Promises (</p>
  
  <ol>
  <li><code>createUserWithEmail...()</code></li>
  <li><code>updateUserProfile()1</code></li>
  <li><code>createUser()</code></li>
  </ol>
  
  <p>) which Are dependent on each other.. How do I use them in one function?</p>
  
  <p><strong>NB</strong>: Couldn't use the <code>functions.auth.user().onCreate()</code> method because of the user type field</p>
  
  <p>How do I write this method without using the <code>.then()</code> ? 
  Some users aren't appearing in the database</p>