Loading...
Error: {{ error.message }}
```
### With Options
```ts
const { data } = await useFetch('/api/posts', {
// Query parameters
query: { page: 1, limit: 10 },
// Request body (for POST/PUT)
body: { title: 'New Post' },
// HTTP method
method: 'POST',
// Only pick specific fields
pick: ['id', 'title'],
// Transform response
transform: (posts) => posts.map(p => ({ ...p, slug: slugify(p.title) })),
// Custom key for caching
key: 'posts-list',
// Don't fetch on server
server: false,
// Don't block navigation
lazy: true,
// Don't fetch immediately
immediate: false,
// Default value
default: () => [],
})
```
### Reactive Parameters
```vue
```
### Computed URL
```vue
```
## useAsyncData
For wrapping any async function:
```vue
```
### Multiple Requests
```vue
```
## $fetch
For client-side events (form submissions, button clicks):
```vue
```
**Important**: Don't use `$fetch` alone in setup for initial data - it will fetch twice (server + client). Use `useFetch` or `useAsyncData` instead.
## Return Values
All composables return:
| Property | Type | Description |
|----------|------|-------------|
| `data` | `Ref