title: How to use an async function in another function?
body: <p>I want to call an async function making an API call inside another function. </p>
  
  <p>Specifically in the code below I am defining an asynchronous function <code>verifyEmail</code> making an API call to a verification service for mail adresses. The function is working when I test it with a random email.</p>
  
  <p>I would like to be able to call this function inside the <code>getProfileInfos</code> function that parses a json file and return an array of objects. The <code>verifyEmail(result.dropcontact.email)</code>is wrong since it will always return the non-resolved <code>Promise</code>. I did some research but do not find the right syntax to call the async function and wait for the result to set the email in my object. </p>
  
  <p>Any help is appreciated!</p>
  
  <pre><code>const verifyEmail = async (email) =&gt; {
    const response = await fetch(`https://apilayer.net/api/check?access_key=******&amp;email=${email}`);
    const data = await response.json();
    if (data.format_valid &amp;&amp; data.score &gt; 0.5) {
      return data.email;
    };
  }
  
  const getProfileInfos = (data) =&gt; {
    const jsonData = JSON.parse(data);
    const results = jsonData.map((result) =&gt; {
      if (result.general) {
        const firstName = result.general.firstName;
        const lastName = result.general.lastName;
        const company = result.jobs[0].companyName;
        const jobTitle = result.jobs[0].jobTitle;
        const email = result.dropcontact ? verifyEmail(result.dropcontact.email) : undefined;
        return {
          firstName,
          lastName,
          company,
          jobTitle,
          email
        }
      }
    });
    return results;
  }
  </code></pre>