NodeJS Function returning undefined

3589 views javascript

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;

answered question

1 Answer


your companysList function doesn't return anything

posted this

Have an answer?


Please login first before posting an answer.