Is it possible to call an existing Javascript function?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Nobel

So I have a pretty superficial knowledge about GDScript and JavaScript, however, I finished making a javascript gRPC web code that can request responses from the backend, and I made a function called GetHealth() that returns a JSON.

What I want is to call that function and use its value, perhaps in a label or something; is that possible? If anyone can explain me or link me to anywhere making something similar I would be grateful.

My theory is that I have to do something like this:

var response = JavaScript.eval( /* function calling */ )

However, I have no idea where my game needs to be placed or what I have to type to call that specific function. I also figured I can perhaps use localStorage, but I don’t think that’s a very straight-forward way to do it.

To be even more specific, the function I wanna call is inside a npm project that has a few libraries installed, responsible to convert/compile and read a .proto file, and my objective is to make a game web page.

:bust_in_silhouette: Reply From: Calinou

Godot 3.4 has a JavaScript interface that makes GDScript ↔ JavaScript interaction easier. I recommend upgrading and giving it a try. (Make a backup of your project beforehand, just in case.)