Reputation: 165
at main.js
I got user information with access_token from oauth.
now I want to change value at index.html with user name
here, how can I send user name to index.html
?
I know event.sender.send
but isn' it located at ipcMain.on
a result of ipcRenderer.send
?
I want to sent some value after I got access_token
thanks
Upvotes: 0
Views: 2205
Reputation: 10227
Assuming that your index.html page is just the main page of your renderer process and isn't an external page that you're hosting in a <webview>
, you can just send the value to the renderer and have it change whatever it needs to change in your index.html:
index.html:
<p id="myParagraph"></p>
<script> require("./renderer.js"); </script>
main.js:
const mainWindow = new BrowserWindow({...});
mainWindow.loadFile("./index.html");
// ... later we get the `accessToken`
mainWindow.webContents.send("got-access-token", accessToken);
renderer.js:
ipcRenderer.on("got-access-token", (event, accessToken) => {
document.getElementById("myParagraph").innerText = accessToken;
});
Upvotes: 3