From a02c408f933aea6f405ed3c64ab151b01b33ae9e Mon Sep 17 00:00:00 2001 From: bptato Date: Sun, 30 Apr 2023 12:19:24 +0200 Subject: WIP fetch --- src/html/env.nim | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/html/env.nim') diff --git a/src/html/env.nim b/src/html/env.nim index 7f270e58..58bad005 100644 --- a/src/html/env.nim +++ b/src/html/env.nim @@ -3,6 +3,8 @@ import streams import html/dom import html/htmlparser import io/loader +import io/promise +import io/request import js/javascript import types/url @@ -51,6 +53,10 @@ proc addNavigatorModule(ctx: JSContext) = ctx.registerType(PluginArray) ctx.registerType(MimeTypeArray) +proc fetch(window: Window, req: Request): Promise[Response] {.jsfunc.} = + if window.loader.isSome: + return window.loader.get.fetch(req) + proc newWindow*(scripting: bool, loader = none(FileLoader)): Window = result = Window( console: console(err: newFileStream(stderr)), -- cgit 1.4.1-2-gfad0