mirror of
https://github.com/syumai/workers.git
synced 2025-03-10 17:29:11 +00:00
R: fix illegal invocation error
This commit is contained in:
parent
83be8bc604
commit
86f9f1cf26
@ -15,7 +15,8 @@ func fetch(namespace js.Value, req *http.Request, init *RequestInit) (*http.Resp
|
||||
if namespace.IsUndefined() {
|
||||
return nil, errors.New("fetch function not found")
|
||||
}
|
||||
promise := namespace.Call("fetch",
|
||||
fetchObj := namespace.Get("fetch")
|
||||
promise := fetchObj.Invoke(
|
||||
// The Request object to fetch.
|
||||
// Docs: https://developers.cloudflare.com/workers/runtime-apis/request
|
||||
jshttp.ToJSRequest(req),
|
||||
@ -23,9 +24,11 @@ func fetch(namespace js.Value, req *http.Request, init *RequestInit) (*http.Resp
|
||||
// Docs: https://developers.cloudflare.com/workers/runtime-apis/request#requestinit
|
||||
init.ToJS(),
|
||||
)
|
||||
|
||||
jsRes, err := jsutil.AwaitPromise(promise)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return jshttp.ToResponse(jsRes)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user