• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

256
Views
Node js , cannot retrive data from sqlight3 table

async function  get_info(compName)  {
    let company   = {
        name:""
        , activityNumber:""
        , siret :""
        , adresse :""
        , tva :""
        , logo:0
    };
    buff = await db.all("SELECT * FROM company WHERE name = ?", [compName], (err, rows) => {
        if (err) {
            console.log(err)
            return err;
        }
        rows.forEach(element => {
            console.log(element.name) // WORK
            company.name =   element.name;
            company.activityNumber =  element.activityNumber;
            company.adresse = element.adresse;
            company.logo =  element.logo;
            company.siret =  element.siret;
            company.tva =  element.tva;
        });
       
    });
    console.log(" ... " + company.name) // DOSENT WORK
    return company;
}

I'm trying to get company fill and get data out of my database. The first console.log() is good but not the second one, it's empty, and the object it returns have defaults values, there will be only one element who will match "WHERE name = ?" so I don't worry about erasing the value.

about 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error