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:
onclick= () =>{
fetch('data.txt')
.then(function(response){
return response.text();
}).then(function (data) {
console.log(data);
})
};
And the button which calls it:
<button onClick={this.onclick}>click string</button>