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

378
Views
method to combine multiple query result(node-postgres) in nodejs express.js response.json

I followed a tutorial to send query results obtained from pg to response.json in node.js and express.js . code given below

const getUsers = (request, response) => {
  pool.query('SELECT * FROM users ORDER BY id ASC', (error, results) => {
    if (error) {
      throw error
    }
    response.status(200).json(results.rows)
  })
}

but I am not to find any tutorial to send multiple query results something like below.

const getUsers = (request, response) => {
  pool.query('SELECT * FROM users ORDER BY id ASC', (error, results1) => {
    if (error) {
      throw error
    })
  }).then(  pool.query('SELECT * FROM provider ORDER BY id ASC', (error, results2) => {
    if (error) {
      throw error
    }
    response.status(200).json({"query1":results1.rows, "query2":results2.rows} )
  }
})
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!