From 5a3b8954b5d5cd41be21dc2e13ca40f6fd3a7813 Mon Sep 17 00:00:00 2001 From: Jay Date: Sat, 13 Jul 2024 05:21:22 +0000 Subject: [PATCH] docs (rpc): multiple parameters --- docs/guides/rpc.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/docs/guides/rpc.md b/docs/guides/rpc.md index 2b3e6c07..4c271a10 100644 --- a/docs/guides/rpc.md +++ b/docs/guides/rpc.md @@ -176,6 +176,41 @@ const res = await client.posts[':id'].$get({ }) ``` +### Multiple Parameters + +Handle routes with multiple parameters. + +```ts +const route = app.get( + '/posts/:postId/:authorId', + zValidator( + 'query', + z.object({ + page: z.string().optional(), + }) + ), + (c) => { + // ... + return c.json({ + title: 'Night', + body: 'Time to sleep', + }) + } +) +``` + +Add multiple `['']` to specify params in path. + +```ts +const res = await client.posts[':postId'][':authorId'].$get({ + param: { + postId: '123', + authorId: '456', + }, + query: {}, +}) +``` + ## Headers You can append the headers to the request.