title: Rest API Multiple Lists in SharePoint
body: <p>Because SharePoint works async i cannot store the data from multiple lists in array's and access them later.</p>
  
  <p>I need to use 3 lists because they contain data from employees, holidays, and more.</p>
  
  <p>See my code below for more information.</p>
  
  <p>Is there no easier way to work with SharePoint and multiple lists to get the data. I tried also with executequeryasync but i cannot find a working solution for multiple lists. Or  to store the value of each list in an array or variable and use it in another function because it's async.</p>
  
  <pre><code>$(function () {
  $('#title').html("Inloggen verlofaanvraag");
  });
  
  
  function inLoggen() {
  var initialen = $('#initialen').val();
  var wachtwoord = $('#wachtwoord').val();
  
  $.ajax({
      url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('Lijst werknemers')/Items?$filter=wInitialen eq '" + initialen + "' and wWachtwoord eq '" + wachtwoord + "'",
      type: "GET",
      headers: { "accept": "application/json;odata=verbose" },
      success: function (data) {
          var x = data.d.results;
          var werknemers = data.d.results;
          for (var i = 0; i &lt; x.length; i++) {
              rInitialen = x[i].wInitialen;
              rWachtwoord = x[i].wWachtwoord;
              rVolledigenaam = x[i].wVolledigenaam;
  
          }
  
          if (i === 0) {
              alert("U hebt geen toegang tot deze pagina !");
          }
          else {
              $('#title').html("Welkom " + rVolledigenaam);
              $('#inlogform').hide();
              persoonlijketellers(werknemers);
          }
      },
      error: function (xhr) {
          console.log(xhr.status + ': ' + xhr.statusText);
      }
  });
  }
  
  
  function persoonlijketellers(werknemers) {
  
  var rId = werknemers[0].ID;
  
  $.ajax({
      url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('Lijst persoonlijke tellers')/Items?$filter=pWerknemer eq '" + rId + "'",
      type: "GET",
      headers: { "accept": "application/json;odata=verbose" },
      success: function (data) {
          var x = data.d.results;
          var ptellers = data.d.results;
          for (var i = 0; i &lt; x.length; i++) {
  
          }
  
          wettelijkeverlofdagen(werknemers, ptellers);
  
      },
      error: function (xhr) {
          console.log(xhr.status + ': ' + xhr.statusText);
      }
  });
  }
  
  function wettelijkeverlofdagen(werknemers, ptellers) {
  
  var rId = ptellers[0].ID;
  
  alert(rId);
  
  $.ajax({
      url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('Lijst persoonlijke tellers')/Items?$filter=pWerknemer eq '" + rId + "'",
      type: "GET",
      headers: { "accept": "application/json;odata=verbose" },
      success: function (data) {
          var x = data.d.results;
          var ptellers = data.d.results;
          for (var i = 0; i &lt; x.length; i++) {
  
          }
  
      },
      error: function (xhr) {
          console.log(xhr.status + ': ' + xhr.statusText);
      }
  });
  }
  </code></pre>