The CWA is in heavy development
The CWA is still in alpha and not ready for production - some code and implementations are likely to change. If you would like to try out the CWA, please enjoy what we have provided and feel free to provide feedback, or get involved on GitHub.
DraftUtilities
useCwaResourceEndpoint
Resolves the correct API endpoint URL for a resource, accounting for draft/published state in admin edit mode.
import { useCwaResourceEndpoint } from '#imports'
const endpoint = useCwaResourceEndpoint(iri)
// endpoint.value → '/component/titles/018e-...' (or '...?published=false' in admin edit mode)
useCwaResourceEndpoint returns a ComputedRef<string> that appends ?published=false when the admin is in edit mode, and returns the plain IRI otherwise. Use it when you need to make manual API requests that respect the current publish state — for example fetching additional data for a resource that isn't automatically loaded by the resource store.
Parameters
| Parameter | Type | Description |
|---|---|---|
iri | Ref<string> | The resource IRI |
postfix | string? | Optional path postfix appended before the query string (e.g. '/children') |
Example
const props = defineProps<IriProp>()
const endpoint = useCwaResourceEndpoint(toRef(props, 'iri'))
const { data } = await useFetch(endpoint)
The composable is used internally by useCwaResource and useCwaCollectionResource — you only need it when building custom fetch logic outside of those composables.