how to store Node js db response into a variable

I have a pcs.db with post codes and their geolocation coordinates. I am trying to extract locations from given code name.

I am able to console log the result, but am unable to store the result into a variable.

I tried .then(function) as I believe db each returns a promise. 4 hours later I am in the same spot I started in. Please help.

const sqlite3 = require('sqlite3').verbose()

    const getCoords = function (postcode) {
      let db = new sqlite3.Database('./pcs.db');
      let sql = `SELECT long, lat FROM postcodes WHERE code='${postcode}'`;

      db.each(sql, [], (err, row) => {
        if (err) {
          throw err;
        }
         console.log(row);
      });
      
      // close the database connection
      db.close();
      }

      getCoords('SM4 4')