Skip to content

Commit

Permalink
fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
unnoq committed Dec 29, 2024
1 parent 1ee6424 commit 72c1a36
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions apps/content/content/docs/client/vanilla.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,19 @@ client.post.
## Client Context

```ts twoslash
import type { router } from 'examples/server'
import { createORPCClient, ORPCError } from '@orpc/client'
import { ORPCLink } from '@orpc/client/fetch'
import type { router } from 'examples/server'

type ClientContext = { cache?: string, tags?: string[] } | undefined
type ClientContext = { cache?: RequestCache } | undefined
// if context is not undefinable, it will require you pass context in every call

const orpcLink = new ORPCLink<ClientContext>({
url: 'http://localhost:3000/api',
// headers: provide additional headers
fetch: (input, init, context) => globalThis.fetch(input, {
...init,
cache: context.cache,
tags: context.tags,
cache: context?.cache,
}),
})

Expand All @@ -66,9 +65,9 @@ client.getting({ name: 'unnoq' }, { context: { cache: 'force-cache' } })
## Dynamic Link

```ts twoslash
import { createORPCClient, ORPCError } from '@orpc/client'
import { ORPCLink } from '@orpc/client/fetch'
import type { router } from 'examples/server'
import { createORPCClient, DynamicLink, ORPCError } from '@orpc/client'
import { ORPCLink } from '@orpc/client/fetch'

const orpcLink1 = new ORPCLink({
url: 'http://localhost:3000/api',
Expand All @@ -80,7 +79,7 @@ const orpcLink2 = new ORPCLink({
// headers: provide additional headers
})

const dynamicLink = new DynamicLink<ClientContext>((path, input, options) => { // can be async
const dynamicLink = new DynamicLink((path, input, options) => { // can be async
// const clientContext = options.context
if (path.includes('post')) {
return orpcLink1
Expand Down

0 comments on commit 72c1a36

Please sign in to comment.