Skip to content

Commit

Permalink
fix: default to GET for http req method (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
nilslice authored May 8, 2024
1 parent fdaa04b commit f1bd0a9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/core/src/prelude/src/http.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
declare global {
interface HttpRequest {
url: string;
// method defaults to "GET" if not provided
method?:
| "GET"
| "HEAD"
Expand Down Expand Up @@ -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],
);
},
});
Expand Down

0 comments on commit f1bd0a9

Please sign in to comment.