diff options
author | bptato <nincsnevem662@gmail.com> | 2023-09-08 11:34:29 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-09-08 11:34:29 +0200 |
commit | ccacdb2b1d735b0708d006fd6c82df98ea0b96c9 (patch) | |
tree | 3a7d2a61f9e4a739df0746274fb76182759753a3 /src/display/client.nim | |
parent | 34af03d4f5baa24b6a8c25434bc26b92fe24a11a (diff) | |
download | chawan-ccacdb2b1d735b0708d006fd6c82df98ea0b96c9.tar.gz |
fetch: allow string input, allow init dictionary
Diffstat (limited to 'src/display/client.nim')
-rw-r--r-- | src/display/client.nim | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/display/client.nim b/src/display/client.nim index c531e4a6..d5140de8 100644 --- a/src/display/client.nim +++ b/src/display/client.nim @@ -36,6 +36,7 @@ import ips/serversocket import ips/socketstream import js/base64 import js/domexception +import js/error import js/fromjs import js/intl import js/javascript @@ -104,8 +105,10 @@ proc finalize(client: Client) {.jsfin.} = proc doRequest(client: Client, req: Request): Response {.jsfunc.} = return client.loader.doRequest(req) -proc fetch(client: Client, req: Request): FetchPromise {.jsfunc.} = - return client.loader.fetch(req) +proc fetch[T: Request|string](client: Client, req: T, init = none(JSValue)): + JSResult[FetchPromise] {.jsfunc.} = + let req = ?newRequest(client.jsctx, req, init) + return ok(client.loader.fetch(req)) proc interruptHandler(rt: JSRuntime, opaque: pointer): int {.cdecl.} = let client = cast[Client](opaque) |