Answer the question
In order to leave comments, you need to log in
How to store the contents of an external Csv file into a variable in Javascript?
I can't figure out what I'm doing right? I need to transfer the body of the Csv file to a variable
const url = "http://www.aaa.com/uploads/1.csv"; //
fetch(url, {
mode: "no-cors",
headers: {
'Content-Type': 'text/csv'
}
})
.then(response => {
return response.ok ? response.text() : Promise.reject(response.status);
})
.then(text => {
return console.log(text.toString())
})
.catch(error => console.log("Can’t access " + url + " response. Blocked by browser?" + error))
Can’t access http://www.aaa.com/uploads/1.csv response. Blocked by browser? 0
Answer the question
In order to leave comments, you need to log in
Can't access www.aaa.com/uploads/1.csv response. Blocked by browser? 0
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question