title: MEAN stack async call seems to be getting fired before a response is received
body: <p>I'm making a request to a node.js server from an Angular application and need to wait until I get a response from the server before continuing. There seems to be something wrong with my async call, but I can't figure out what it is.</p>
  
  <p>This is my login component:</p>
  
  <pre><code>  onLogin() {
      if (this.form.invalid) {
        console.log(this.form);
        console.log('Form invalid');
        return;
      }
      this.isLoading = true;
      const findUserType = () =&gt; {
        return new Promise(resolve =&gt; {
          resolve(this.authService.getUserType(this.form.value.username));
        });
      };
      async function asyncCall() {
        console.log('getting user type');
        const result = await findUserType().then(userType =&gt; {
          console.log(userType);
        });
      }
  </code></pre>
  
  <p>Making a request through the authservice:</p>
  
  <pre><code>  getUserType(username: string) {
      this.http.post&lt;{ message: string; }&gt;(
        'http://localhost:3000/api/user/find-user',
        { username }
      )
      .subscribe(response =&gt; {
        console.log(response.message);
        return response.message;
      });
    }
  </code></pre>
  
  <p>Which is grabbing the data from nodejs:</p>
  
  <pre><code>router.post('/find-user', (req, res, next) =&gt; {
    function checkHauler() {HaulerUser.countDocuments({ username: req.body.username }, function (err, count) {
        if (count &gt; 0) {
          return res.status(200).json({
            message: 'isHauler'
          })
        }
      });
    }
    function checkAbf() {AbfUser.countDocuments({ username: req.body.username }, function (err, count) {
        if (count &gt; 0) {
          return res.status(200).json({
            message: 'isAbf'
          })
        }
      });
    }
    function checkUtility() {UtilityUser.countDocuments({ username: req.body.username }, function (err, count) {
        if (count &gt; 0) {
          return res.status(200).json({
            message: 'isUtility'
          })
        }
      });
    }
    Promise.all([checkHauler(), checkAbf(), checkUtility()])
      .then(() =&gt; {
        console.log('done')
    })
  </code></pre>
  
  <p>This is what shows in my console:</p>
  
  <pre><code>getting user type
  undefined
  result: undefined
  
  Uncaught TypeError: Cannot read property 'type' of undefined
      at setFieldValue (onloadwff.js:71)
      at HTMLFormElement.formKeydownListener (onloadwff.js:71)
  
  isAbf
  </code></pre>
  
  <p>I'm very new to all of this and any help would be appreciated!!</p>