How to import a .txt file from my source?

I’ve solved my problem.

  handleClick = () => {

    fetch('/sample.txt')
    .then((r) => r.text())
    .then(text  => {
      console.log(text);
    })  
  } 

Tis link did help:
Fetch local JSON file from public folder ReactJS

Leave a Comment