Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing the GET method option on the server$ utility #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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: () => <div>Hello World!</div>,
}))
const fn = lazy(() =>
import$({
default: () => <div>Hello World!</div>,
}),
)
```

Output:
Expand Down Expand Up @@ -265,6 +267,6 @@ console.log(result) // 'Hello World!'
</details>
<!-- Use the force, Luke! -->

- [`websocket$`](#websocket)
- [`lazy$`](#lazy)
- [`interactive$`/`island$`](#interactive)
- [`websocket$`](#websocket)
- [`lazy$`](#lazy)
- [`interactive$`/`island$`](#interactive)
2 changes: 1 addition & 1 deletion packages/bling/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type FetchFnReturn<T extends AnyFetchFn> = Awaited<

export type CreateFetcherFn = <T extends AnyFetchFn>(
fn: T,
opts?: FetchFnCtxWithRequest,
opts?: FetchFnCtxWithRequest | FetchFnCtxOptions,
) => Fetcher<T>

export type FetcherFn<T extends AnyFetchFn> = (
Expand Down
4 changes: 4 additions & 0 deletions packages/bling/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down