title: Using IPC layer and contextBridge to send data to renderer in Electron
body: <p>I took out the irrelevant parts:</p>
  <p>main.js</p>
  <pre><code>let window = null;
   app.on('ready', () =&gt; {
      window = new BrowserWindow({
          webPreferences: {
              nodeIntegration: false,
              contextIsolation: true,
              enableRemoteModule: false,
              preload: path.join(__dirname, &quot;preload.js&quot;)
          }
      });
  
      window.loadFile('index.html')
          .then(() =&gt; {})
          .catch(err =&gt; console.log(err));
  });
  </code></pre>
  <p>I have a timeout in main.js that calls</p>
  <pre><code>window.webContents.send('store-data', &quot;MESSAGE&quot;);
  </code></pre>
  <p>preload.js</p>
  <pre><code>const {contextBridge,ipcRenderer} = require('electron');
  
  contextBridge.exposeInMainWorld('electron', {
      storeData: (channel, data) =&gt; {
          ipcRenderer.on(channel, (event, data) =&gt; {
              return data;
          });
      }
  });
  </code></pre>
  <p>index.html</p>
  <pre><code>window.electron.storeData('store-data', (data) =&gt;{
      console.log(data);
  });
  </code></pre>
  <p>This is working in that I get an object on the index.html side, but no data.</p>