I'm following the SO answer here: https://stackoverflow.com/questions/72119191/electron-contextbridge-returns-undefined/72121733#72121733
To be able to use fs.open in my Electron project. I have it working as long as I have a function that is hard-coded to open one specific file every time, but I don't know how to pass a variable to it in order to be able to fs.open whatever I need to in the given situation
This is working with a hard-coded file path in fiddle: https://gist.github.com/SushiKishi/bb5cc09a66f13c7a2e72dd0cac9ae032
This is my non-working attempt to open based on a variable: https://gist.github.com/SushiKishi/17de131debdbd3ee77be49e73b811341
I know WHY the second one throws an error, but don't know how to go about fixing it. In FileOps.js, line 24:
ipcMain.handle('channel-load-file', async (event, message) => {
return await openFile( file )
//moving on...
it's throwing the "file not defined" error. If instead of "file" there I put:
return await openFile( 'credits.js' )
then openFile takes credits.js as the value for "file" and opens it as it should. But I don't know how to get that line of code to get a definition for a variable; in my index.html file when I use:
('click', () => { window.electronAPI.loadFile('credits.js')
that value doesn't seem to go anywhere because there's nowhere for it to go on the other end, and that's where I think I'm stuck.
https://gist.github.com/SushiKishi/23c6a0f56acc9c3bfaa439f4f394f4c4