I'm trying to write some javascript that first reads a local csv file, updates it and overwriter the original with its new value. Using console.log() I can confirm that I can read the file, but when I try to upload it using POST i get error message 405 'net::ERR_ABORTED 405 (Method not allowed'. what is wrong?
async function getData() {
var a = performance.now();
const response = await fetch("runnerDB2.csv");
const data = await response.text();
const lines = data.split("\n");
const CSVData = [];
for (let i = 0; i < lines.length; i++) {
CSVData[i] = lines[i].split(",");
}
console.log(CSVData[1][3]);
CSVData[1][3] = 5;
console.log(CSVData[1][3]);
let text = CSVData.toString();
console.log(text);
fetch('/upload', {
method: 'POST',
body: text,
headers: {
'Content-type': 'text/plain'}
});
var b = performance.now()
alert('Time for execution: ' + (b-a) + 'ms.');
}
