Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

328
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda