From 91411e9b100050f78792f6eb824173496f07062b Mon Sep 17 00:00:00 2001 From: Zack DeRose Date: Thu, 4 May 2023 13:14:35 -0700 Subject: [PATCH] fixing the GET method option on the server$ utility --- README.md | 18 ++++++++++-------- packages/bling/src/types.ts | 2 +- packages/bling/src/utils/utils.ts | 4 ++++ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0f38497..723ebc6 100644 --- a/README.md +++ b/README.md @@ -127,13 +127,13 @@ The `secret$` function can be used to scope any expression to the server (secret ```tsx import { secret$ } from '@tanstack/bling' -const secretMessage = secret$('It is a secret!')') +const secretMessage = secret$('It is a secret!') ``` Server Output: ```tsx -const secretMessage = server$('It is a secret!')') +const secretMessage = server$('It is a secret!') ``` Client Output: @@ -183,9 +183,11 @@ This can be used to code-split React/Solid components too: import { import$ } from '@tanstack/bling' import { lazy } from 'react' -const fn = lazy(() => import$({ - default: () =>
Hello World!
, -})) +const fn = lazy(() => + import$({ + default: () =>
Hello World!
, + }), +) ``` Output: @@ -265,6 +267,6 @@ console.log(result) // 'Hello World!' - - [`websocket$`](#websocket) - - [`lazy$`](#lazy) - - [`interactive$`/`island$`](#interactive) +- [`websocket$`](#websocket) +- [`lazy$`](#lazy) +- [`interactive$`/`island$`](#interactive) diff --git a/packages/bling/src/types.ts b/packages/bling/src/types.ts index 41cb005..3bd5ec5 100644 --- a/packages/bling/src/types.ts +++ b/packages/bling/src/types.ts @@ -21,7 +21,7 @@ export type FetchFnReturn = Awaited< export type CreateFetcherFn = ( fn: T, - opts?: FetchFnCtxWithRequest, + opts?: FetchFnCtxWithRequest | FetchFnCtxOptions, ) => Fetcher export type FetcherFn = ( diff --git a/packages/bling/src/utils/utils.ts b/packages/bling/src/utils/utils.ts index d93985f..53b830f 100644 --- a/packages/bling/src/utils/utils.ts +++ b/packages/bling/src/utils/utils.ts @@ -267,6 +267,10 @@ export function resolveRequestHref( ? `${pathname}?payload=${encodeURIComponent(payloadInit.body as string)}` : pathname + if (method.toLocaleLowerCase() === 'get') { + delete payloadInit.body + } + return new URL( resolved, typeof document !== 'undefined' ? window.location.href : `http://localhost`,