useLazySanctumFetch

Besides useSanctumClient you can directly send a request by using a module-specific version of fetch composable - useLazySanctumFetch .

This composable implements the same interface as useLazyFetch, so you can check more details here.

components/YourComponent.vue
const { data, status, error, refresh } = await useLazySanctumFetch('/api/users');

You can also use type casting to work with response as an interface:

interface MyResponse {
  name: string
}

const { data } = await useLazySanctumFetch<MyResponse>('/api/endpoint')

const name = data.value.name // augmented by MyResponse interface

Last updated