Comments (3)
It's 'fetch's issue. Look at its API.
from goja.
Judging by the error you tried something like this:
vm.Set("self", map[string]interface{}{})
You definitely don't want to do this. It creates a JS wrapper around the map and every time you put a JS value into it, the value will be Export()'ed and then every time you reference it from JS it will be wrapped again. (Aside of this, the reason for the error is those wrapped maps are not extensible by default. Can't remember if there was a good reason for me to do it this way, probably not, I'll change it).
If you want to set it to an empty object it could be done like this:
vm.Set("self", vm.NewObject())
However, in browsers 'self' appears to be the global object, so to make it more compatible you should do the same. I'll probably add something like vm.GlobalObject(), but for now you can do this:
vm.RunString("var self = this")
from goja.
That's very interesting! I will definitely try this.
from goja.
Related Issues (20)
- How to Throw an Error From the Golang Function
- What Is Types Marshaling Among JS and GOLANG Spaces.
- Support for setting a Promise as handled to true HOT 3
- how to impove performance for a amount of constant literal in a javascript file HOT 4
- vm reuse problem HOT 2
- Request for Assistance: Obtaining Abstract Syntax Tree (AST) with Goja HOT 1
- How to limit the number of for loops HOT 1
- Fibers/Coroutines HOT 4
- Builtin Date locale's methods ignore locale argument HOT 1
- Export JS array to Go slice HOT 2
- if i want to let users do js on my server like cloudflare workers, is it possible to use your repo to do so? HOT 1
- abnormal string input to js function HOT 1
- Go binding for function rest params does not work as expected HOT 2
- how to register custom object into goja like before? HOT 3
- Listing class properties HOT 5
- Circular References Memory Leak HOT 1
- BUG: String.split on an empty string may produces unexpected results HOT 1
- Runtime clears its own interrupt HOT 1
- Object.keys with map[int]any will return <int Value> HOT 2
- RegExp dont support dotAll flag
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from goja.