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

181
Views
In javascript how can we return data inside of a try catch

I have sqlite database and I am trying to return data from the variable named results. Currently I get undefined. Not sure how to return value from try catch

const checkEntry = async (activeProfile, item) => {
    try {
      return await db.transaction(async tx => {
        return await tx.executeSql(
          'SELECT * FROM MidiMap WHERE profileId="' + activeProfile + '"',
          [],
          (sqlTx, res) => {
            console.log('Scene check data retrieved successfully');
            let len = res.rows.length;

            if (len > 0) {
              let results = [];
              for (let i = 0; i < len; i++) {
                let item = res.rows.item(i);
                results.push({id: item.id, name: item.name});
              }
              // Need to return the data from results
              return results;
            }
          },
          error => {
            console.log('error on getting midi mapping ' + error.message);
          },
        );
      });
    } catch (error) {
      console.error(error);
    }
  };

I am calling the function like this however I get undefined

checkEntry().then((r)=>{
  console.log(r)
})
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!