| 361 | } |
| 362 | |
| 363 | export function adapter(config: Record<string, unknown>) { |
| 364 | const { baseURL, url, params, data: body, ...rest } = config; |
| 365 | const path = baseURL ? `${baseURL}${url}` : url; |
| 366 | const fetchUrl = params |
| 367 | ? `${path}?${new URLSearchParams(params as any).toString()}` |
| 368 | : path; |
| 369 | return fetch(fetchUrl as string, { ...rest, body }).then((res) => { |
| 370 | const { status, headers, statusText } = res; |
| 371 | return res |
| 372 | .text() |
| 373 | .then((data: string) => ({ status, statusText, headers, data })); |
| 374 | }); |
| 375 | } |
| 376 | |
| 377 | export function safeLocalStorage(): { |
| 378 | getItem: (key: string) => string | null; |