mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-31 20:28:07 +01:00
remove asyncdata helpers
This commit is contained in:
43
README.md
43
README.md
@@ -58,24 +58,6 @@ Use the client like so:
|
||||
<script setup lang="ts">
|
||||
const client = useClient()
|
||||
|
||||
const data = await client.query('hello')
|
||||
|
||||
console.log(data) // => 👈 world
|
||||
</script>
|
||||
```
|
||||
|
||||
## Composables
|
||||
|
||||
Composables are auto-imported.
|
||||
|
||||
### `useClient()`
|
||||
|
||||
A typesafe client with the `createTRPCClient` method from `@trpc/client`.
|
||||
|
||||
```html
|
||||
<script setup lang="ts">
|
||||
const client = useClient()
|
||||
|
||||
const bilbo = await client.query('getUser', 'id_bilbo');
|
||||
// => { id: 'id_bilbo', name: 'Bilbo' };
|
||||
|
||||
@@ -83,28 +65,3 @@ const frodo = await client.mutation('createUser', { name: 'Frodo' });
|
||||
// => { id: 'id_frodo', name: 'Frodo' };
|
||||
</script>
|
||||
```
|
||||
|
||||
### `useClientQuery`
|
||||
|
||||
`client.query` wrapped in [`useAsyncData`](https://v3.nuxtjs.org/guide/features/data-fetching/#useasyncdata).
|
||||
|
||||
```html
|
||||
<script setup lang="ts">
|
||||
const { data, pending, refresh, error } = await useClientQuery('getUser', 'id_bilbo');
|
||||
|
||||
console.log(data.value) // => { id: 'id_frodo', name: 'Frodo' };
|
||||
</script>
|
||||
```
|
||||
|
||||
### `useLazyClientQuery`
|
||||
|
||||
`client.query` wrapped in [`useLazyAsyncData`](https://v3.nuxtjs.org/guide/features/data-fetching/#uselazyasyncdata).
|
||||
|
||||
```html
|
||||
<script setup lang="ts">
|
||||
const { data, pending, refresh, error } = await useLazyClientQuery('getUser', 'id_bilbo');
|
||||
|
||||
console.log(data.value) // => { id: 'id_frodo', name: 'Frodo' };
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user