In my nuxt 3 App, for data fetching I wanna set a baseURL for all my API calls. As I get this baseURL from enviroment variable. How to set the the baseURL?
I warp the useFetch
with composables, but then I can't get the baseURL as useRuntimeConfig()
is not accessable there.
// My composables function
const baseURL = "how to get baseURL from process.env";
export const myFetch = async (url: string) => {
const options = {
baseURL: baseURL,
};
return await useFetch(url, options);
}