import { BACKEND_URL } from "../config/constants"; | |
export async function apiFetch( | |
endpoint: string, | |
options: RequestInit = {}, | |
): Promise<Response> { | |
const url = `${BACKEND_URL}${endpoint}`; | |
const defaultOptions: RequestInit = { | |
credentials: "include", | |
headers: { | |
"Content-Type": "application/json", | |
...options.headers, | |
}, | |
...options, | |
}; | |
return fetch(url, defaultOptions); | |
} | |