Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

219
Visualizações
Cannot get Object from RowDataPacket

I have this code on my router.js:

conexion.query('SELECT * FROM log WHERE id= ?',[id],(error,results)=>{
var user = results[0].user}) 

so when I run this terminal says 'TypeError: Cannot read properties of undefined (reading 'user')'

I know that results is a RowDataPacket cause if I do a console.log(results) it's comes in a RowDataPacket form, so the code above makes sense to me to be right, but obviously I'm missing something.

The log table from mysql have 4 fields (id,user,date,error).

I have try this format before and it worked, even with the same table but others fields.

Already have checked that user is a varchar and if I try something like

var user = results[1].user

nothing show up from that.

And cannot try to 'SELECT user FROM log..' cause gonna need the other fields later in the code too and even the result still comes in a RowDataPacket from.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda