import Cookies from 'js-cookie' export const useRequest = (request, method="GET" ,opts={}, headers ={}) => { let locale = Cookies.get('i18n_redirected'); const config = useRuntimeConfig() const options = { 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 $fetch(request, options) }