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

295
Views
JavaScript: error de referencia no detectado: el nombre de usuario no está definido

empiezo a programar un chat pero siempre me sale este error:

Error de referencia no capturado: el nombre de usuario no está definido

Pero definí const nombre de usuario = usuario.displayName;

esta es una parte de mi código:

 function authStateListener() { firebase.auth().onAuthStateChanged((user) => { if (user) { const username = user.displayName; } else { window.location.href = "../pages/login.html"; } }); };

y ahi esta el error:

 fetchChat.on("child_added", function (snapshot) { const messages = snapshot.val(); const now = (new Date().toLocaleDateString()).split("."); const t = (messages.date).split("."); if( t[0] < now[0]) { const message = `<li class=${username === messages.username ? "sent" : "receive"}><span class="name">${messages.username} </span><br>${messages.message}<br><span class="time">${t[0] - now[0]} Days ago</span></li>`; addMsg(message); } else { const message = `<li class=${username === messages.username ? "sent" : "receive"}><span class="name">${messages.username} </span><br>${messages.message}<br><span class="time">${messages.time}</span></li>`; addMsg(message); } //const message = `<li class=${username === messages.username ? "sent" : "receive"}></span>${messages.message}</li>`; });

Espero que puedas ayudarme

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!