score:2

Accepted answer

When using Create React App everything in the public directory will be available at the root of your site, so you can move the dataset.json file there and just fetch /dataset.json instead.

componentDidMount() {
  fetch("/dataset.json")
    .then(response => response.json())
    .then(json => {
      console.log(json);
    })
    .catch(error => console.error(error));
}

Related Query

More Query from same tag