about summary refs log tree commit diff stats
path: root/src/html/env.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-09-08 11:34:29 +0200
committerbptato <nincsnevem662@gmail.com>2023-09-08 11:34:29 +0200
commitccacdb2b1d735b0708d006fd6c82df98ea0b96c9 (patch)
tree3a7d2a61f9e4a739df0746274fb76182759753a3 /src/html/env.nim
parent34af03d4f5baa24b6a8c25434bc26b92fe24a11a (diff)
downloadchawan-ccacdb2b1d735b0708d006fd6c82df98ea0b96c9.tar.gz
fetch: allow string input, allow init dictionary
Diffstat (limited to 'src/html/env.nim')
-rw-r--r--src/html/env.nim6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/html/env.nim b/src/html/env.nim
index f48407e3..687c577a 100644
--- a/src/html/env.nim
+++ b/src/html/env.nim
@@ -66,9 +66,11 @@ proc addNavigatorModule(ctx: JSContext) =
   ctx.registerType(PluginArray)
   ctx.registerType(MimeTypeArray)
 
-proc fetch(window: Window, req: Request): FetchPromise {.jsfunc.} =
+proc fetch[T: Request|string](window: Window, req: T, init = none(JSValue)):
+    JSResult[FetchPromise] {.jsfunc.} =
   if window.loader.isSome:
-    return window.loader.get.fetch(req)
+    let req = ?newRequest(window.jsctx, req, init)
+    return ok(window.loader.get.fetch(req))
 
 proc setTimeout[T: JSValue|string](window: Window, handler: T,
     timeout = 0i32): int32 {.jsfunc.} =