Download src/lib/apiClient.ts from sitcod3/modul-s: direct link, hf CLI and curl.
- Browser
- Download file 753 Bytes
-
https://huggingface.co/spaces/sitcod3/modul-s/resolve/main/src/lib/apiClient.ts
- Command line
-
hf download hf://spaces/sitcod3/modul-s/src/lib/apiClient.ts
-
curl -L -o apiClient.ts https://huggingface.co/spaces/sitcod3/modul-s/resolve/main/src/lib/apiClient.ts
753 Bytes
| import axios from "axios"; | |
| export const apiClient = axios.create({ | |
| baseURL: "/api", | |
| }); | |
| apiClient.interceptors.request.use((config) => { | |
| // Only access localStorage in browser environment | |
| if (typeof window !== 'undefined') { | |
| const keysStr = localStorage.getItem("smartlead_api_keys"); | |
| const activeId = localStorage.getItem("smartlead_active_key_id"); | |
| if (keysStr && activeId) { | |
| try { | |
| const keys = JSON.parse(keysStr); | |
| const activeKey = keys.find((k: any) => k.id === activeId)?.key; | |
| if (activeKey) { | |
| config.headers["x-api-key"] = activeKey; | |
| } | |
| } catch (e) { | |
| console.error("Failed to parse API keys", e); | |
| } | |
| } | |
| } | |
| return config; | |
| }); | |