title: How can I make a function return something that is inside of a .onload
body: <p>This is my function, how can I make it so that openFileBrowse() returns the outcome of the function tsvJSON() inside of the reader.onload?</p>
  
  <pre><code>export function openFileBrowse() {
    var input = document.getElementById("filebutton");
    if (input.files[0].type != "application/vnd.ms-excel"){
      alert("You have uploaded a wrong file type. We require a .csv file not a " + input.files[0].type + " file.");
    } else {
      var reader = new FileReader();
      var aftertext = "";
      reader.onload = function(){
        aftertext = reader.result;
        return tsvJSON(aftertext);
      };
      reader.onloadend = function(){
        console.log("loading finished");
      };
      reader.readAsText(input.files[0]);
    }
  }
  </code></pre>
  
  <p>Thanks in advance!</p>