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

213
Views
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
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!