UNPKG

api-wizard

Version:

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

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