Components
Composables
$fetch
Send HTTP requests with the auto-imported ofetch client.
$fetch is a direct reference to ofetch.
const project = await $fetch<Project>("/api/projects/42");const created = await $fetch<Project>("/api/projects", {
method: "POST",
body: {
name: "Documentation",
},
});The client parses JSON responses automatically and throws on failed HTTP responses. To get caching, reactive state, and SSR hydration, call $fetch inside useAsyncData().