useStatamicApi composable. If you need more control or want to create a custom fetch instance on your server side, this function is for you.The createFetchInstance function is a utility function that creates a configured fetch instance for making requests to the Statamic API.
It is recommended to use the $api instance that the module provides via the plugin.
<script setup lang="ts">
const { $api } = useNuxtApp()
</script>
If you want to create a custom fetch instance (on your server side for example), you can easily use the createFetchInstance function.
export default defineCachedEventHandler(async (event: H3Event) => {
const api = createFetchInstance()
});
function createFetchInstance(options?: FetchOptions): $Fetch
process.env.NUXT_PUBLIC_STATAMIC_URLprocess.env.NUXT_DEBUG is set to true or debug mode is enabled in the module configuration