I'm building a chrome extension that relies on accessing a csv file. Currently, I'm hosting the csv file remotely on Github. I'm using fetch() to get the url, then using .text() on the response object to get it into a usable format. The problem is, my code is returning the entire HTML of the github webpage, when all I want is the contents of the file. Here is my code:
function fetchCSV(){
var corsProxy = "https://cors-anywhere.herokuapp.com/"; //having CORS issues so using a cors proxy currently
var url = "https://github.com/path/to/file/data.csv";
return fetch(corsProxy + url)
.then((responseObj)=>{
return responseObj.text();
});
return true; // Will respond asynchronously.
}
console.log(fetchCSV()); //returns a promise object with resolve value that contains entire github webpage html
So, how do I get just the contents of the CSV file, and not the entire webpage?