title: reactJS and reading a text file
body: <p>I have a reactJS application where I need to read in a large text file and use the data from the file to populate some arrays.  I came across some code examples and I am trying to implement this code:</p>
  
  <pre><code>        readTextFile = file =&gt; {
          var rawFile = new XMLHttpRequest();
          rawFile.open("GET", file, false);
          rawFile.onreadystatechange = () =&gt; {
              if (rawFile.readyState === 4) {
                  if (rawFile.status === 200 || rawFile.status == 0) {
                      var allText = rawFile.responseText;
                      console.log("allText: ", allText);
                      this.setState({
                          fundData: allText
                      });
                  }
              }
          };
          rawFile.send(null);
      };
  </code></pre>
  
  <p>The code is called by executing this line of code:</p>
  
  <pre><code>this.readTextFile("../text/fund_list.txt");
  </code></pre>
  
  <p>When I execute the application, I get the following error message:</p>
  
  <blockquote>
    <p>GET <a href="http://localhost:8080/text/fund_list.txt" rel="noreferrer">http://localhost:8080/text/fund_list.txt</a> 404 (Not Found)</p>
  </blockquote>
  
  <p>This is what my application structure looks like:
  <a href="https://i.stack.imgur.com/g9F3a.png" rel="noreferrer"><img src="https://i.stack.imgur.com/g9F3a.png" alt="enter image description here"></a></p>
  
  <p>The readTextFile function is in the account_balanc.js code and I am trying to read in the text file /text/fund_list.txt.  The file does exist so obviously I am not referencing the file correctly but I don't know why.</p>
  
  <p>I have tried this.readTextFile("../text/fund_list.txt") and this.readTextFile("./text/fund_list.txt"); but neither worked.  I even tried moving fund_list.txt into the /screens folder and changing the function call to this.readTextFile("fund_list.txt"); but I still get the 404 error message.</p>
  
  <p>Any ideas why?</p>
  
  <p>Thank you.</p>