UNPKG

api-wizard

Version:

A powerful TypeScript wrapper for native Fetch API with token management, interceptors, and type-safe HTTP requests

19 lines (18 loc) 712 B
const createFetchDefaults = ({ baseUrl = "/api", option, }) => { const { version, contentType, charset, accept, withCredentials = true, // 기본값 true (axios와 동일) } = option ?? {}; const headers = {}; if (contentType) headers["Content-Type"] = [contentType, charset && `; charset=${charset}`].join(""); if (accept) headers["Accept"] = accept; return { baseURL: typeof version !== "undefined" ? [baseUrl, version].join("/") : baseUrl, headers: headers, credentials: withCredentials ? "include" : "omit", }; }; const fetchRequestConfig = { credentials: "include", // 기본값 }; export { createFetchDefaults, fetchRequestConfig };