Download src/api/client.js from NKessler/Horizon: direct link, hf CLI and curl.
- Browser
- Download file 824 Bytes
-
https://huggingface.co/NKessler/Horizon/resolve/main/src/api/client.js
- Command line
-
hf download hf://NKessler/Horizon/src/api/client.js
-
curl -L -o client.js https://huggingface.co/NKessler/Horizon/resolve/main/src/api/client.js
824 Bytes
| /** Fetch JSON from `/api/*` (Vite proxies to FastAPI). */ | |
| async function http(path, params) { | |
| const qs = params | |
| ? "?" + new URLSearchParams(params).toString() | |
| : ""; | |
| const res = await fetch(`/api${path}${qs}`); | |
| if (!res.ok) throw new Error(`HTTP ${res.status} for ${path}`); | |
| return res.json(); | |
| } | |
| export async function fetchMeta(query) { | |
| return http("/meta", query); | |
| } | |
| export async function fetchCountryDivergence(query) { | |
| return http("/map/divergence", query); | |
| } | |
| export async function fetchMapArticles(query, iso = null) { | |
| const params = iso ? { ...query, iso } : query; | |
| return http("/map/articles", params); | |
| } | |
| export async function fetchTimeline(query) { | |
| return http("/timeline", query); | |
| } | |
| export async function fetchContrastingGroups(query) { | |
| return http("/contrasting-groups", query); | |
| } | |