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

165
Views
Cómo puedo actualizar mis datos Json en Express.js

Necesito ayuda:

Guardé el ping de mi bot de Discord en un archivo JSON y quiero mostrar el ping del archivo JSON en mi servidor web usando HTML. Estoy usando Express.js.

Esta es una imagen de los datos, pero no se actualiza cuando cambia en el archivo JSON.

ingrese la descripción de la imagen aquí

Esto en mi proyecto expreso:

 app.get('/', function(req, res){ const pingsBots = require('./Database/BotPing.json') const pingofbot = pingsBots.thepingofbot.botping let file = fs.readFileSync(path.join(__dirname, './html/', 'main.html'), { encoding: 'utf-8' }) file = file.replace("$$theping$$", pingofbot) res.sendFile(path.join(__dirname, './html/', 'main.html')) res.send(file) })

Y esto en método listo en mi bot:

 setInterval(function(){ let Pusher = JSON.parse(fs.readFileSync('./Database/BotsPing.json', 'utf8')); Pusher["thepingofbot"] = { botping: `${client.ws.ping}` } async function SavePingData(path, JSONdata){ fs.writeFileSync(path, JSON.stringify(JSONdata, null, 2)) } SavePingData('./Database/BotsPing.json', Pusher) }, 1000)

Por cierto: proyecto Express no con el proyecto bot.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

app.get('/', function(req, res){ const pingsBots = require('./Database/BotPing.json') const pingofbot = pingsBots.thepingofbot.botping let file = fs.readFileSync(path.join(__dirname, './html/', 'main.html'), { encoding: 'utf-8' }) file = file.replace("$$theping$$", pingofbot) res.sendFile(path.join(__dirname, './html/', 'main.html')) })
about 4 years ago · Juan Pablo Isaza Report
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!