0

I'm trying to fetch .csv data in react, however it returns as it below. I'm not sure why does it happen.

["<!DOCTYPE html>↵<html lang="en">↵  <head>↵    <met…tatic/js/main.chunk.js"></script></body>↵</html>↵"]

My code to fetch data.

 async function getDummyData (){
      const URL = '../MockData/dummyData.csv';
      let data = await fetch(URL);
      data = await data.text();
      let dummyData = CSV.split('\r\n');
    }
    getDummyData();

However, code works as it should be on Vanilla JS and returns data of 100 paragraphs.

Thanks in advance for any help.

Çetin
  • 117
  • 2
  • 6
  • possible duplicate of https://stackoverflow.com/questions/53416529/react-import-csv-file-and-parse – Rixcy Feb 15 '21 at 17:03
  • The URL you have points to an HTML document (it looks like the bootstrap HTML document that loads your React application). Likely this is a server configuration issue. – Quentin Feb 15 '21 at 17:12

0 Answers0