This commit is contained in:
Mehdi104797 2025-04-03 13:27:09 +03:30
parent 5d62e751b3
commit 219f12c2b2

View File

@ -8,8 +8,8 @@ export default defineNuxtPlugin((nuxtApp) => {
const api = $fetch.create({ const api = $fetch.create({
onRequest({ request, options, error }) { onRequest({ request, options, error }) {
options.baseURL = options.baseURL =
config.public.NUXT_PUBLIC_BASE_URL + config.public.VITE_BASE_URL +
config.public.NUXT_PUBLIC_API_NAME + config.public.VITE_API_NAME +
options.baseURL; options.baseURL;
if (token) { if (token) {
@ -38,10 +38,10 @@ export default defineNuxtPlugin((nuxtApp) => {
// Add custom methods for GET, POST, and DELETE // Add custom methods for GET, POST, and DELETE
const http = { const http = {
getRequest: (url, options = {}) => api(url, { method: "GET", ...options }), getRequest: (url: string, options = {}) => api(url, { method: "GET", ...options }),
postRequest: (url, body, options = {}) => postRequest: (url: string, body: any, options = {}) =>
api(url, { method: "POST", body, ...options }), api(url, { method: "POST", body, ...options }),
deleteRequest: (url, options = {}) => deleteRequest: (url: string, options = {}) =>
api(url, { method: "DELETE", ...options }), api(url, { method: "DELETE", ...options }),
}; };