Hi, I’m trying to get a String from a database using JavaScriptBridge calling a function called getOpenField() which uses a “Promise” object and I don’t know how to handle that object from GDScript. With this I mean wait for the promise state to be " fulfilled" and then get the String from that object.
this is probably because javascriptbridge.eval() returns a Variant, and Godot doesn’t have a promise Variant class.
you need a JavaScriptObject class which is usually gotten with JavaScriptBridge.get_interface(<interface string>)
You may need to create a custom interface that will wrap your function with a the promise. and you can abstract the then function.
// suedo js
const MyInterface = {
getOpenField: function () { },
then: function (args) { },
};
# suedo gd
var my_interface : JavaScriptObject = JavaScriptBridge.get_interface("MyInterface")
There are also other means to setup callbacks documented in the JavaScriptBridge class.
-----
this is because i did not define a valid function body for the callback in my post. just replace the three periods with the pass keyword if you don’t have a function in mind yet. (I was attempting to convey that you will implement whatever you need.)