Created
March 24, 2025 12:17
-
-
Save randercarlos/6976b6f10fb277ea2ff028636f04b076 to your computer and use it in GitHub Desktop.
Custom Fetch with Interceptors in Nuxt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const useCustomFetch = (url: string, options?: FetchOptions) => { | |
| return useFetch(url, { | |
| ...options, | |
| async onResponse({ request, response, options }) { | |
| console.log('[fetch response]') | |
| }, | |
| async onResponseError({ request, response, options }) { | |
| console.log('[fetch response error]') | |
| }, | |
| async onRequest({ request, options }) { | |
| console.log('[fetch request]') | |
| }, | |
| async onRequestError({ request, options, error }) { | |
| console.log('[fetch request error]') | |
| } | |
| }) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment