mirror of
https://github.com/syumai/workers.git
synced 2025-03-11 01:39: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() {
|
if namespace.IsUndefined() {
|
||||||
return nil, errors.New("fetch function not found")
|
return nil, errors.New("fetch function not found")
|
||||||
}
|
}
|
||||||
promise := namespace.Call("fetch",
|
fetchObj := namespace.Get("fetch")
|
||||||
|
promise := fetchObj.Invoke(
|
||||||
// The Request object to fetch.
|
// The Request object to fetch.
|
||||||
// Docs: https://developers.cloudflare.com/workers/runtime-apis/request
|
// Docs: https://developers.cloudflare.com/workers/runtime-apis/request
|
||||||
jshttp.ToJSRequest(req),
|
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
|
// Docs: https://developers.cloudflare.com/workers/runtime-apis/request#requestinit
|
||||||
init.ToJS(),
|
init.ToJS(),
|
||||||
)
|
)
|
||||||
|
|
||||||
jsRes, err := jsutil.AwaitPromise(promise)
|
jsRes, err := jsutil.AwaitPromise(promise)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return jshttp.ToResponse(jsRes)
|
return jshttp.ToResponse(jsRes)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user