Closed wwwAngHua closed 9 months ago
I first ran the axios js library, but I couldn't get the axios object. What happened?
package main import ( "fmt" "github.com/dop251/goja" "io/ioutil" "net/http" ) func main() { vm := goja.New() axiosSrc, err := ioutil.ReadFile("axios.js") if err != nil { panic(err) } _, err = vm.RunString(string(axiosSrc)) if err != nil { panic(err) } _, err = vm.RunString(` axios.get('https://jsonplaceholder.typicode.com/todos/1') .then(function (response) { console.log(response.data); }) .catch(function (error) { console.log(error); }); `) if err != nil { panic(err) } }
error message:
ReferenceError: axios is not defined at main (:2:5(1))
Without seeing the contents of axios.js I can only make an educated guess that it did not set globalThis.axios.
I first ran the axios js library, but I couldn't get the axios object. What happened?
error message:
ReferenceError: axios is not defined at main (:2:5(1))