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

142
Vistas
Run terminal(?) in browser

Basically, what I want to do is:

I have this data that I get using XHR and display it in browser.

[
    {
        "name": "task1",
        "todo": "Complete online Javascript course"
    },
    {
        "name": "task2",
        "todo": "Jog around the park 3x"
    },
    {
        "name": "task3",
        "todo": "10 minutes meditation"
    }
]
let dataUse = []

getData = () => {
    const xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status ==200) {
            const myData = JSON.parse(this.responseText)
            dataUse.push.apply(dataUse, myData)
        }
    }
    xhttp.open("GET", "data.json", true);
    xhttp.send();
}

getData()

And what I want to do is, I want to have a box where I can add new data to the JSON file.

saveData = () =>{
    myData.push(newData)

    const fs = require('fs')
    const finished = (error) =>{
        if(error){
            console.error(error)
            return
        }
    }
    
    const jsonData = JSON.stringify(myData, null, 2)
    fs.writeFile('data.json', jsonData, finished)
}

The problem is this line of code needs to be run through the terminal in order for it to write the new data into the file, so I want to know if there is a way to run the terminal in browser through some kind of function or something.

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