Created
August 17, 2023 11:38
-
-
Save Fanreza/c2d5282d8d4a12d79e89f00a9b118d32 to your computer and use it in GitHub Desktop.
Nuxt composable useFetch with global options and interceptors
This file contains 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
import { useFetch } from "#app"; | |
type useFetchType = typeof useFetch; | |
export const useHttp: useFetchType = (path, options = {}) => { | |
const config = useRuntimeConfig(); | |
options.baseURL = config.public.baseUrl; | |
options.onResponseError = (error) => {}; | |
return useFetch(path, options); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment