sanctum:request
Subscribe to hook and react to a request sent to your Laravel API.
When your Nuxt application sends any request against the Laravel API, you can subscribe to the sanctum:request
hook the same way as the ofetch interceptor onRequest
. More details about interceptors can be found here - interceptors.
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.hook('sanctum:request', (nuxtApp, context, logger) => {
logger.info('Sanctum request hook triggered', context.request)
})
})
Here is what the hook looks like
interface RuntimeNuxtHooks {
/**
* Triggers on every client request.
*/
'sanctum:request': (app: NuxtApp, ctx: FetchContext, logger: ConsolaInstance) => HookResult
}
Last updated