1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { fetch } from "https://esm.town/v/std/fetch";
export async function fetchFigmaFile(apiToken, fileKey) {
const url = `https://api.figma.com/v1/files/${fileKey}`;
const response = await fetch(url, {
headers: {
"X-FIGMA-TOKEN": apiToken,
},
});
if (!response.ok) {
console.error("Failed to fetch Figma file");
return null;
}
const data = await response.json();
return data;
}