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

189
Views
SQlite result undefined issue in NodeJS

I'm having a problem with seemingly textbook example of SQlite usage:

Code below

const db_client = new sqlite3.Database(HISTORY_DB, (err) => {
  if (err) {
    console.error(err.message, '## ERROR ##');
    return;
  }
  console.log('Connected to the SQlite DB');
});

const current_hour = new Date().getHours();
const sql = `SELECT value FROM history where hour = ${current_hour}`;

const getSql = async (sql) => {
  await db_client.get(sql, [], (err, row) => {
    if (err) {
      return console.error(err.message);
  } 
    console.log(row.value, 'FIRST');
    return parseInt(row.value);
  })
};
console.log(await getSql(sql), 'SECOND');

For some reason I cannot get the value of the sql response. I've tried a couple of approaches and its always undefined, but console.log works. I cannot figure it out.

Console log pasted below:

undefined SECOND
Connected to the SQlite DB
287439002531265 FIRST
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!