How to return arrow function from function [duplicate]

This is my code:

const db = new sqlite3.Database(

function getPageContent(sqlQuery) {
  db.all(sqlQuery, [], (err, rows) => {
    if (err) {
      console.log("Something went wrong in the db");
    } else {
      rows.forEach((row) => {
        let content = row.page_content;
        return content;
  getPageContent(`SELECT page_content FROM fruit WHERE page_name = "apples";`)

The console log is undefined.

I´m pretty sure it is because I need to return more things inside these nested function on more "levels", like in this post:
Return value from nested function in Javascript
but I don´t know how to implement that in my own code, primarily since I have arrow functions.

Leave a Reply

Your email address will not be published.