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

170
Views
NodeJs - read Json file and return the json data

I have a function wich reads some JSON data from a file an I want to return that data. This actually works right now, BUT when I log the global Variable USERS then on the first func call it's undefined and on the second call I get the right value. Does somebody know why ?

My Function:

async function readJson() {
fs.readFile('./src/users.json', 'utf-8', (err, data) => {
    if (err) {
        console.error(`Fehler: ${err}`)
    } else {
        USERS = JSON.parse(data)
    }
})
   return USERS
}

Thanks for all answers

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!