From f1bd0a91762813fb8856949952a2b23f0f85e9f6 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Wed, 8 May 2024 15:38:53 -0600 Subject: [PATCH] fix: default to GET for http req method (#73) --- crates/core/src/prelude/src/http.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/core/src/prelude/src/http.ts b/crates/core/src/prelude/src/http.ts index 422a7d1..a277809 100644 --- a/crates/core/src/prelude/src/http.ts +++ b/crates/core/src/prelude/src/http.ts @@ -1,6 +1,7 @@ declare global { interface HttpRequest { url: string; + // method defaults to "GET" if not provided method?: | "GET" | "HEAD" @@ -31,12 +32,16 @@ Http.request = new Proxy(Http.request, { body = new Uint8Array(body).toString(); } + if (req.method === undefined) { + req.method = "GET"; + } + return Reflect.apply( target, thisArg, // TODO: We need to completely avoid passing a second argument due to a bug in the runtime, // which converts `undefined` to `"undefined"`. This is also the case for req.method. - body !== undefined ? [req, body] : [req] + body !== undefined ? [req, body] : [req], ); }, });