title: Store contents of fileReader in a variable
body: <p>trying to do something that I feel like should be releatively straight forward.</p>
  
  <p>I just want to read a text files content and store it in a variable.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>readToCSV(file) {
  // console.log(file);
  
      let cat = "";
  
      var reader = new FileReader();
      reader.onloadend = function (event) {
          if (event.target.readyState == FileReader.DONE) {
              var data = event.target.result;
          }
          console.log("data:", data)
          cat = data;
      };
  
      reader.readAsText(file)
      console.log("cat:",cat);
  
  
  };
  </code></pre>
  
  <p>Ive tried just about everything, and keep getting undefined outside the function. Do i just have to nest any further processing inside the onloadend function. That seems silly.</p>