2

Hello I would like to be able to insert the result of a function written in python that I get in the variable data but when I tried to insert the value of this variable, the command document.getElementById("h1-fs-s5").innerHTML does not execute with the value of data when trying to concatenate and an error appears.

Here is a part of the code:

subpy.stdout.on('data',function(data){
          console.log("data: ",data.toString('utf8'));
            mainWindow.webContents.executeJavaScript(` document.getElementById("h1-fs-s5").innerHTML = "${data.toString('utf8')}" ; `);
          });

Here is the error that i have :

(node:2208) UnhandledPromiseRejectionWarning: Error: Script failed to execute, this normally means an error was thrown. Check the renderer console for the error.
    at WebFrame.<computed> (C:\Users\cantr\Desktop\Stage ing├®nieur KOMILFO SPORT\Sail Vision\Dashboard\node_modules\electron\dist\resources\electron.asar\renderer\api\web-frame.js:64:33)
    at WebFrame.executeJavaScript (C:\Users\cantr\Desktop\Stage ing├®nieur KOMILFO SPORT\Sail Vision\Dashboard\node_modules\electron\dist\resources\electron.asar\common\api\deprecate.js:114:32)
    at C:\Users\cantr\Desktop\Stage ing├®nieur KOMILFO SPORT\Sail Vision\Dashboard\node_modules\electron\dist\resources\electron.asar\renderer\web-frame-init.js:11:43
    at C:\Users\cantr\Desktop\Stage ing├®nieur KOMILFO SPORT\Sail Vision\Dashboard\node_modules\electron\dist\resources\electron.asar\renderer\ipc-renderer-internal-utils.js:7:40
    at new Promise (<anonymous>)
    at EventEmitter.<anonymous> (C:\Users\cantr\Desktop\Stage ing├®nieur KOMILFO SPORT\Sail Vision\Dashboard\node_modules\electron\dist\resources\electron.asar\renderer\ipc-renderer-internal-utils.js:7:9)
    at EventEmitter.emit (events.js:200:13)
    at Object.onMessage (C:\Users\cantr\Desktop\Stage ing├®nieur KOMILFO SPORT\Sail Vision\Dashboard\node_modules\electron\dist\resources\electron.asar\renderer\init.js:42:16)
(node:2208) UnhandledPromiseRejectionWarning: Error: Script failed to execute, this normally means an error was thrown. Check the renderer console for the error.
    at WebFrame.<computed> (C:\Users\cantr\Desktop\Stage ing├®nieur KOMILFO SPORT\Sail Vision\Dashboard\node_modules\electron\dist\resources\electron.asar\renderer\api\web-frame.js:64:33)
    at WebFrame.executeJavaScript (C:\Users\cantr\Desktop\Stage ing├®nieur KOMILFO SPORT\Sail Vision\Dashboard\node_modules\electron\dist\resources\electron.asar\common\api\deprecate.js:114:32)
    at C:\Users\cantr\Desktop\Stage ing├®nieur KOMILFO SPORT\Sail Vision\Dashboard\node_modules\electron\dist\resources\electron.asar\renderer\web-frame-init.js:11:43
    at C:\Users\cantr\Desktop\Stage ing├®nieur KOMILFO SPORT\Sail Vision\Dashboard\node_modules\electron\dist\resources\electron.asar\renderer\ipc-renderer-internal-utils.js:7:40
    at new Promise (<anonymous>)
    at EventEmitter.<anonymous> (C:\Users\cantr\Desktop\Stage ing├®nieur KOMILFO SPORT\Sail Vision\Dashboard\node_modules\electron\dist\resources\electron.asar\renderer\ipc-renderer-internal-utils.js:7:9)
    at EventEmitter.emit (events.js:200:13)
    at Object.onMessage (C:\Users\cantr\Desktop\Stage ing├®nieur KOMILFO SPORT\Sail Vision\Dashboard\node_modules\electron\dist\resources\electron.asar\renderer\init.js:42:16)  
(node:2208) 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:2208) 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:2208) [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.
(node:2208) [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.

Regards,

1 Answer 1

1

The problem was with the data type returned by the python program, so I converted data via the parseInt(data) function to make it work and not with toString('utf8').

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.