Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

329
Views
How to update local txt/csv file using javascript fetch

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.');
}

console error screendump

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!