title: How to wait unitl xhr finished?
body: <p>I'm making a website where I need to get all people who are registered to an event but every time I make the xhr request the code execute and do not wait the xrh response, that's cause a lot of trouble in the following code...</p>
  <pre><code>let inscrit = new XMLHttpRequest();
  let methode = &quot;GET&quot;;
  let url = &quot;php/getInscrit.php&quot;;
  let asynchronous = true;
  
  inscrit.open(methode, url, asynchronous);
  inscrit.timeout = 4000;
  inscrit.onload = function () {
    let people;
  
    if (this.readyState == 4 &amp;&amp; this.status == 200) {
      people = JSON.parse(this.responseText);
    }
  };
  inscrit.send(null);
  return people;
  </code></pre>
  <p>Sorry for my bad English and ty</p>