Raffael-Kultyshev commited on
Commit
0b43131
·
verified ·
1 Parent(s): 44a055f

Fix: Add HF_TOKEN to fetchJson for 401 error

Browse files
Files changed (1) hide show
  1. src/utils/parquetUtils.ts +10 -1
src/utils/parquetUtils.ts CHANGED
@@ -25,7 +25,16 @@ export interface DatasetMetadata {
25
  }
26
 
27
  export async function fetchJson<T>(url: string): Promise<T> {
28
- const res = await fetch(url);
 
 
 
 
 
 
 
 
 
29
  if (!res.ok) {
30
  throw new Error(
31
  `Failed to fetch JSON ${url}: ${res.status} ${res.statusText}`,
 
25
  }
26
 
27
  export async function fetchJson<T>(url: string): Promise<T> {
28
+ // Get token from environment (set in Space secrets)
29
+ const hfToken = process.env.HF_TOKEN;
30
+ const headers: HeadersInit = {};
31
+
32
+ // Add Authorization header if token is available
33
+ if (hfToken) {
34
+ headers["Authorization"] = `Bearer ${hfToken}`;
35
+ }
36
+
37
+ const res = await fetch(url, { headers });
38
  if (!res.ok) {
39
  throw new Error(
40
  `Failed to fetch JSON ${url}: ${res.status} ${res.statusText}`,