Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

217
Views
Returning values from a Promise to a React Component using Electron and contextBridge and sqlite3

I am trying to connect a SQLite3 database with a react component using electron contextBridge and continue to return a promise {<pending>} in my frontend react component. I have rapped my SQL call in a new Promise.

Quotes_mgr.js

exports.getActiveQuoteData = () => {
  return new Promise(( resolve , reject ) => {
    db.serialize(() => {
        db.all(
          "SELECT * FROM Quotes ",
          (err, rows) => {
            if (err) reject(err);
            resolve(rows);
          }
        );})
      }) 
};

This function is called with electrons ipcMain.handle in my main.js file.

main.js

  ipcMain.handle("get_active_quotes", (event) => {
    return Quotes_mgr.getActiveQuoteData();
    //return Employee_mgr.getEmployeeid(args);
  });

through the contextBridge api in the preload.js file.

preload.js

contextBridge.exposeInMainWorld("api", {
  on(eventName, callback) {
    ipcRenderer.on(eventName, callback);
  },

    getActiveQuotes: () => ipcRenderer.invoke("get_active_quotes"),
});

Then returns the SQL results to my React component.

index.jsx

const getInStore_List = async () => {
    return await window.api.getActiveQuotes();
  }
  const InStore_List = getInStore_List()

InStore_List returns a promise {<pending>} containing the SQL results but I need it to return the SQL results so i can use them in my React component. I am new to Promises and Async functions and believe that the problem is in my new Promise implantation but have not been able to figure out why this is not working. Any help would be appreciated.

about 4 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 Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!