// import { useI18n } from 'vue-i18n'; import Cookies from 'js-cookie'; // let BASE_URL = 'http://localhost:6060/appapi'; let BASE_URL = 'https://prodio.zltest.com.tw/appapi'; // const { apiBaseUrl: BASE_URL } = runtimeConfig export function request(url, method = 'GET', data = {}, headers = {}) { // const { locale } = useI18n() let locale = Cookies.get('i18n_redirected'); return new Promise((resolve, reject) => { const newOptions = { baseURL: BASE_URL, method: method, headers: { "Content-Type": "application/json", // "Authorization": Cookies.get('token'), ...headers, } }; data = { ...data, lang: locale } if (method === "GET" || method === "DELETE") { newOptions.params = data; } if (method === "POST" || method === "PUT") { newOptions.body = data; } useFetch(url, newOptions) .then((res) => { resolve(res.data); }) .catch((error) => { reject(error); }); }); } export function requestC(url, method = 'GET', data = {}, headers = {}) { // const { locale } = useI18n() let locale = Cookies.get('i18n_redirected'); return new Promise((resolve, reject) => { const newOptions = { baseURL: BASE_URL, method: method, headers: { "Content-Type": "application/json", // "Authorization": Cookies.get('token'), ...headers, } }; data = { ...data, lang: locale } if (method === "GET" || method === "DELETE") { newOptions.params = data; } if (method === "POST" || method === "PUT") { newOptions.body = data; } $fetch(url, newOptions) .then((res) => { resolve(res); }) .catch((error) => { reject(error); }); }); }