mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-14 12:14:40 +01:00
add useTRPCAsyncData composable
This commit is contained in:
18
README.md
18
README.md
@@ -21,7 +21,7 @@ export default defineNuxtConfig({
|
||||
trpcURL: '/api/trpc', // defaults to /api/trpc
|
||||
},
|
||||
typescript: {
|
||||
strict: true // set this to true to infer input/output types
|
||||
strict: true // set this to true to make input/output types work
|
||||
}
|
||||
})
|
||||
```
|
||||
@@ -64,6 +64,22 @@ console.log(farewell); // => 👈 goodbye
|
||||
</script>
|
||||
```
|
||||
|
||||
## `useTRPCAsyncData`
|
||||
|
||||
A composable that wraps Nuxt's [`useAsyncData`](https://v3.nuxtjs.org/api/composables/use-async-data/) with some modifications to have better error handlings.
|
||||
|
||||
```ts
|
||||
const path = 'hello'
|
||||
const client = useClient()
|
||||
|
||||
const {
|
||||
data,
|
||||
pending,
|
||||
error,
|
||||
refresh
|
||||
} = await useTRPCAsyncData(path, () => client.query(path))
|
||||
```
|
||||
|
||||
## Recipes
|
||||
|
||||
- [Validation](/recipes/validation.md)
|
||||
|
||||
Reference in New Issue
Block a user