-
|
so i wanted to use useFetch for my laravel API and i wanted to set the base url to the laravel’s url how i can set the base url once? just like in nuxt2 for axios module |
Beta Was this translation helpful? Give feedback.
Replies: 0 comments 11 replies
-
|
$fetch.create |
Beta Was this translation helpful? Give feedback.
-
|
how about the useFetch? |
Beta Was this translation helpful? Give feedback.
-
|
In that case you can create a wrapper composable: import type { UseFetchOptions } from '#app'
const useMyFetch = (url: string, options: UseFetchOptions<unknown>) => useFetch(url, { baseURL: 'https://my.api/', ...options }) |
Beta Was this translation helpful? Give feedback.
-
|
.env file: composables/useGetFetch.ts: const nuxtApp = useNuxtApp() This works greak. |
Beta Was this translation helpful? Give feedback.
In that case you can create a wrapper composable: