0

I have a function that needs to get data from another function, but the second one is returning undefined and i don't know why.

function firstOne() {
    const companys = companysList();
    console.log(companys); // LOG UNDEFINED
};

.

function companysList(){
    db.query('SELECT id FROM companys WHERE id > 0', (error, result) =>{
        if (error) throw error;
        console.log(JSON.stringify(result)); // LOG THE ids!
        return result;
    });
};
Guilherme
  • 161
  • 3
  • 14

1 Answers1

2

your companysList function doesn't return anything

qiAlex
  • 4,290
  • 2
  • 19
  • 35