From ccacdb2b1d735b0708d006fd6c82df98ea0b96c9 Mon Sep 17 00:00:00 2001 From: bptato Date: Fri, 8 Sep 2023 11:34:29 +0200 Subject: fetch: allow string input, allow init dictionary --- src/html/env.nim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/html/env.nim') 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.} = -- cgit 1.4.1-2-gfad0