sanctum:response

Subscribe to hook and react to a response received from your Laravel API.

When your Laravel API returns any response, you can subscribe to the sanctum:response hook the same way as the ofetch interceptor onResponse. More details about interceptors can be found here - interceptors.

plugins/sanctum-listener.ts
export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.hook('sanctum:response', (nuxtApp, context, logger) => {
    logger.info('Sanctum response hook triggered', context.request)
  })
})

Here is what the hook looks like

interface RuntimeNuxtHooks {
  /**
   * Triggers on every server response.
   */
  'sanctum:response': (app: NuxtApp, ctx: FetchContext, logger: ConsolaInstance) => HookResult
}

Last updated