-
Notifications
You must be signed in to change notification settings - Fork 431
Closed
Description
@dop251
I have this JS script
function doSomething() {
return new Promise((resolve) => {
resolve("https://example.com/");
});
}
globalThis.testpromise = async () => JSON.stringify(await doSomething());
globalThis.testpromise2 = () => doSomething();I am trying to get the final string value out of JS world and into Go world. (Note: In my actual real-world project, doSomething() won't resolve immediately)
This works (returns https://example.com/):
v, err := vm.RunString(`testpromise2()`)
v.Export().(*goja.Promise).Result().Export().(string) // Returns https://example.com/
}However this does not (returns an unresolved promise, that never resolves):
v, err := vm.RunString(`testpromise()`)
v.Export().(*goja.Promise).Result().Export().(string)
}NOTE: v, err := vm.RunString("await testpromise()") produces a JS error.
Metadata
Metadata
Assignees
Labels
No labels