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

197
Views
Devolviendo el archivo config.json actualizado (aplicación MERN)

Estoy usando el módulo del sistema de archivos del nodo por primera vez para almacenar un archivo config.json que podría editarse desde el front-end. Puedo leer crear el archivo config.json y leer el archivo por separado.

Sin embargo, quiero actualizar el archivo y devolver el archivo guardado en la misma solicitud. ¿Cómo hago lo mismo de manera eficiente?

 //To Set config file & return data router.post('/write-config', adminAuth, (req, res) => { console.log(`admin wants to update config`) ; const {config} = req.body ; try { fs.writeFile(__dirname+'/data/config.json', JSON.stringify(config), (err) => { if (err) throw err ; console.log('Configuration saved successfully.') ; }); //res.json("ok") ; /* return the data from file which we just saved */ } catch(err) { console.log(err.message) ; res.status(400).json(err.message) ; } }) ;
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!