title: Why is my ipcMain returning an empty array after reading through a database?
body: <p>For my project, I am using electron and react with ipcRenderer and ipcMain to communicate with a database. I can see it go through the database, but it returns an empty array. It is like the array is returned before anything is read from the db.</p>
  <p>Here is the code I am using in my ipc main:
  I am expecting it to return the names of the categories, but all it returns cateNames blank.</p>
  <pre class="lang-js prettyprint-override"><code>ipcMain.on(channels.GET_CATS, async(event,type) =&gt; {
      console.log(&quot;made it&quot;)
      let cateNames=[];
  
      db.each(`SELECT name FROM categories WHERE type=?`, [type],(err, row) =&gt; {
          if (err) {
              return console.error(err.message);
          }
  
          console.log(row.name);
          cateNames.push(row.name);
      });
      
      console.log(cateNames);
      event.sender.send(channels.GET_LOGIN, cateNames);
  });
  </code></pre>
  <p>I send the request with
  <code>ipcRenderer.send(channels.GET_CATS,&quot;Donation&quot;);</code>
  with an ipcRenderer.on listening that will output the array to the console.</p>