Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

215
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda