title: axios parallel requests parsing a dataTable
body: <p>I've got a dataTables table with accounting data. The purpose is to send the row id to a php script which manages the accounting transfer via SAP and returns a reference number or an error text which should be inserted in the last column. This is working, but in the current version it is done by jQuery ajax in sequential, blocking order which takes it's time. My next attempt to made it quicker is done with axios and I was asking myself, if this is the correct (parallel) way? (I am new to these promises.) </p>
  
  <pre><code>for (var i = 0; i &lt; table.rows().count(); i++) {
      rowData = table.row(i).data();
      axios.post('/test/data', rowData).then(function(response){
          addResultToRow(response);
          // promises.push(axios.post('/test/data', rowData));
      });
  }
  
  function addResultToRow(response){
      rowData = table.row('#'+response.data.id).data();
      rowData.result = response.data.result;
      table.row('#'+response.data.id).data(rowData);
      table.draw();
  }
  </code></pre>
  
  <p>I am thinking, that the request has to take place in the loop, but the ".then" call should be outside. Isn't that construct above blocking the loop until the response is received? I also tried the axios.all() way, but that is displaying all results, when the last response was received:</p>
  
  <pre><code>axios.all(promises).then(function(results) {
      results.forEach(function(response) {
          addResultToRow(response);
      });
  }).catch(function(error){
      console.error(error);
  });
  </code></pre>
  
  <h1>Edit:</h1>
  
  <p>Maybe it is a better way to push all requests into an array:</p>
  
  <pre><code>for (var i = 0; i &lt; table.rows().count(); i++) {
      rowData = table.row(i).data();
      requests.push(
          axios.post('/api/test/data', rowData)
              .then(function(response){
                  addResultToRow(response);
              })
              .catch((error) =&gt; {
                  console.error(error);
              })
      );
  }
  
  function addResultToRow(response){
      rowData = table.row('#'+response.data.id).data();
      rowData.result = response.data.result;
      table.row('#'+response.data.id).data(rowData);
      if (response.data.status === true) {
          $(table.row('#'+response.data.id).node()).addClass('success');
          updateProgressBar();
      } else {
          $(table.row('#'+response.data.id).node()).addClass('danger');
          updateProgressBar();
      }
      table.draw();
  }
  </code></pre>
  
  <p>Works well. Your thoughts?</p>