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

133
Views
siguiente js tratando de almacenar datos en el archivo

Estoy tratando de almacenar cada mensaje nuevo en un archivo js pero no funciona correctamente. no me sale ningun error ni nada...

¿Alguien podría ayudarme con una solución? :)

 const newmessage = { "id": 1, "author": "Knocklive", "content": input } alert(JSON.stringify(newmessage)) fs.writeFileSync("./data/messages/" + chatroomid + ".js", JSON.stringify(newmessage, null, 2) , (err) => { if (err) throw err; });

Mi 1.js antes:

 export const messages = [ { "id": 1, "author": "Knocklive", "content": "TextXYZ" }, { "id": 2, "author": "Knocklive", "content": "TextXYZ" }, { "id": 3, "author": "Knocklive", "content": "TextXYZ" }, ]

Cómo debería verse después de la acción:

 export const messages = [ { "id": 1, "author": "Knocklive", "content": "TextXYZ" }, { "id": 2, "author": "Knocklive", "content": "TextXYZ" }, { "id": 3, "author": "Knocklive", "content": "TextXYZ" }, { "id": 0, "author": "namexy", "content": "contentxyz" }, ]
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!