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

120
Views
Return data from multiple SQLLite tables and pass it to NodeJS endpoint

I have 2 tables in my SQLLite db

Table 1: Location

id name
1 USA
2 UK

Table 2: Components

id name locationId
1 John 1
2 Jack 1
3 Jill 2
4 Sam 2

I have a endpoint like:


app.get('/location/:id', (req, res, next) => {
            const component1= db.all(
           `Select name FROM Components Where locationId = ${req.params.id}`
            ).then(comp => res.json(comp))
            .catch(next)
}

and it returns:

[
                {
                    "name": "John"
                },
                {
                    "name": "Jack"
                }
            ]

BUT the expected result is:

if the endpoint is localhost:8080/location/1 it should return :

{
    name: 'USA',
    components: [
                {
                    "name": "John"
                },
                {
                    "name": "Jack"
                }
            ]
}

I'm using ExpressJS and this endpoint in app.js file

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!