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

309
Views
TypeError: Cannot read properties of undefined (reading 'rows')

Trying to use Express JS with React app and PostgreSQL DB for first time, I am following this tutorial, but editing slightly for my need (recipe storage). I am currently getting this error and not sure why...

TypeError: Cannot read properties of undefined (reading 'rows')
    at /Users/xx/Desktop/Programming/recipes/recipes/backend/node_postgres/recipe_model.js:16:23
    at Query.callback (/Users/xx/Desktop/Programming/recipes/recipes/backend/node_postgres/node_modules/pg-pool/index.js:415:18)
    at Query.handleError (/Users/xx/Desktop/Programming/recipes/recipes/backend/node_postgres/node_modules/pg/lib/query.js:128:19)
    at Client._handleErrorMessage (/Users/xx/Desktop/Programming/recipes/recipes/backend/node_postgres/node_modules/pg/lib/client.js:335:17)
    at Connection.emit (node:events:526:28)
    at /Users/xx/Desktop/Programming/recipes/recipes/backend/node_postgres/node_modules/pg/lib/connection.js:114:12
    at Parser.parse (/Users/xx/Desktop/Programming/recipes/recipes/backend/node_postgres/node_modules/pg-protocol/dist/parser.js:40:17)
    at Socket.<anonymous> (/Users/xx/Desktop/Programming/recipes/recipes/backend/node_postgres/node_modules/pg-protocol/dist/index.js:11:42)
    at Socket.emit (node:events:526:28)
    at addChunk (node:internal/streams/readable:315:12)

The relevant code from recipe_model.js

const getRecipe = () => {
  return new Promise(function (resolve, reject) {
    pool.query('SELECT * FROM recipes ORDER BY id ASC', (error, results) => {
      if (error) {
        reject(error)
      }
      resolve(results.rows)
    })
  })
}

Thanks for any assistance.

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

0

Your query is working fine but rows does't exist in result simple resolve result only and check by console.log what you are getting in result.

Reply me in comment for any query.

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!