export const useMyFetch = (request, method="GET" ,opts={}, headers ={}) => {
    const { locale } = useI18n()
    const config = useRuntimeConfig()

    const options = {
        // baseURL: process.server ? config.private.apiBaseUrl : config.public.apiBaseUrl,
        baseURL: config.public.apiBaseUrl,
        method: method,
        headers: {
            "Content-Type": "application/json",
            // "Authorization": Cookies.get('token'),
            ...headers,
        }
    };

    let data = {
        ...opts,
        lang: locale
    }

    if (method === "GET" || method === "DELETE") {
        options.params = data;
    }
    if (method === "POST" || method === "PUT") {
        options.body = data;
    }

    return useFetch(request, options)
}

