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

141
Views
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
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!