title: How to read text file in react
body: <p><a href="https://i.stack.imgur.com/hULjz.jpg" rel="noreferrer">Screenshot1</a>
  <a href="https://i.stack.imgur.com/kZvWD.jpg" rel="noreferrer">Screenshot2</a></p>
  
  <p>I want to read from a text file within the react project, but when i try to execute and read i get a HTML sample code in the console log. 
  This is the function:</p>
  
  <pre><code>`onclick= () =&gt;{
          fetch('data.txt')
              .then(function(response){
                  return response.text();
              }).then(function (data) {
              console.log(data);
          })
      };`
  </code></pre>
  
  <p>And the button which calls it: </p>
  
  <pre><code>` &lt;button onClick={this.onclick}&gt;click string&lt;/button&gt;`
  </code></pre>