diff options
Diffstat (limited to 'src/html/env.nim')
-rw-r--r-- | src/html/env.nim | 6 |
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.} = |