remove asyncdata helpers

This commit is contained in:
Robert Soriano
2022-05-17 18:04:30 -07:00
parent f4a9d7e127
commit d3b99a6e72
6 changed files with 3 additions and 128 deletions

View File

@@ -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>
```