title: how to make js wait for the result and treatment of fetch request to continuous on?
body: <p>I'm still a js beginner and full of doubts. You guys from stack overflow are helping a lot. Thanks!</p>
  
  <p><strong>Context:</strong> I want to make a fetch request to my API after the user logs in, and verifies if the user is admin or costumer, so then it continues on. To do so, I need to make another request to the user's endpoint to verify it. </p>
  
  <p>The problem is that javascript doesn't wait for the return of the userRole() function to treat it and then print 'ok' to the console. It prints first! </p>
  
  <p>I've tried a lot of solutions but couldn't make it work. </p>
  
  <pre><code>let userRole = async (id, token) =&gt; {
      let response = await fetch(
        `https://lu-teperino-arq-developer.herokuapp.com/usuarios/${id}`,
        {
          method: "GET",
          headers: {
            Authorization: "Basic " + token
          }
        }
      );
      let data = await response.json();
  
      if (data.profissional === true) return "admin";
      else if (data.profissional === false) return "customer";
      else return "";
    };
  
    const userId = "";
    const token = "";
  
    userRole(userId, token).then(data =&gt; {
      console.log(data);
    });
  
    console.log("ok");
  </code></pre>
  
  <p>Can anyone please help me?</p>