electron js cant read preload script function

Viewed 18

I want to run a function to close the app when the user clicks a button.

In my preload I have

const { contextBridge, app } = require('electron')

contextBridge.exposeInMainWorld('mainMethods',{
     quit : () => {
        console.log(app);
app.quit()

}
})

When I call this function from my render script

var quitbutton= document.getElementById('launch');
quitbutton.addEventListener('click',function(){
    window.mainMethods.quit()
  })

The function runs, but returns null for app? Why cant it find app? enter image description here

0 Answers
Related