useStatamicFetch

Gitlab
Fetch data from a Statamic API endpoint using the $api instance.
Added since: v1.0.0
Last changed:

Usage

The useStatamicFetch composable is a wrapper around the useFetch composable that uses the $api instance to fetch data from a Statamic API endpoint.

This is useful when you need to fetch data from a Statamic API endpoint that is not covered by the useStatamicApi composable.

Basic example

pages/[...slug].vue
<script setup lang="ts">
const { 
data
} = await
useStatamicFetch
("/api/tenants");
</script>

Type Definition

function 
useStatamicFetch
<
T
>(
url
: string | (() => string),
options
?:
UseFetchOptions
<
T
>,
)

API Reference

Params

url
string | (() => string)
The URI of the page to fetch
options
UseFetchOptions<T>
The options to pass to the fetch function.

Return Value

AsyncData<T, NuxtError>
Returns a fully configured useFetch composable.

Changelog

v1.0.0

on

#407d36db

-

feat: released initial version of nuxt-statamic