I am trying to make a electron program that could log the text of a TextArea in a HTML file but for some reason I get this error:
(node:8664) UnhandledPromiseRejectionWarning: TypeError: mainWindowHTML.getTextAreaText is not a function at Object.module.exports.Save (C:\Users\user\Documents\JavaScript\node.js\Electron\INTERFACE_EDITOR\menuScripts.js:12:33) at click (C:\Users\user\Documents\JavaScript\node.js\Electron\INTERFACE_EDITOR\index.js:36:37) at MenuItem.click (C:\Users\user\Documents\JavaScript\node.js\Electron\INTERFACE_EDITOR\node_modules\electron\dist\resources\electron.asar\browser\api\menu-item.js:55:9) at Function.executeCommand (C:\Users\user\Documents\JavaScript\node.js\Electron\INTERFACE_EDITOR\node_modules\electron\dist\resources\electron.asar\browser\api\menu.js:30:13) (node:8664) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:8664) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
In my main class I basically load the HTML file into a browser window which works and when a menuitem is clicked it calls this part of my menuScripts.js script:
const url = require('url');
const path = require('path');
module.exports.Save = async(dialog) => {
const mainWindowHTML = url.format({
pathname: path.join(__dirname , "./htmls/MainWindow.html"),
protocol: "file",
slashes: true
});
const text = mainWindowHTML.getTextAreaText();
console.log(text);
}
module.exports.New = async(dialog) => {
}
module.exports.Exit = async(window) => {
window.close();
}
And this is my MainWindow.html file:
<html lang="en">
<head>
<title>document</title>
</head>
<body>
<textarea id="code" cols="30" rows="10"></textarea>
</body>
<script>
module.exports.getTextAreaText = async() => {
return (document.getElementById("code").innerText)
}
</script>
</html>