Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

143
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda