File size: 824 Bytes
4083225
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/** 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);
}