MCPcopy Create free account
hub / github.com/MigoXLab/coderio / fetchFigmaNode

Function fetchFigmaNode

src/tools/figma-tool/figma.ts:12–27  ·  view source on GitHub ↗
(fileId: string, nodeId: string, token: string)

Source from the content-addressed store, hash-verified

10 * @returns Figma frame information
11 */
12export const fetchFigmaNode = async (fileId: string, nodeId: string, token: string): Promise<FigmaFrameInfo | undefined> => {
13 const url = `https://api.figma.com/v1/files/${fileId}/nodes?ids=${nodeId}`;
14 try {
15 const data = await get<{ nodes: Record<string, { document: FigmaFrameInfo }> }>(url, {
16 headers: {
17 'X-Figma-Token': token,
18 },
19 });
20 // format node id to match the format in the response
21 const resData = data.nodes?.[nodeId];
22 return resData?.document;
23 } catch (error) {
24 logger.printErrorLog(`Failed to fetch Figma node: ${error instanceof Error ? error.message : 'Unknown error'}`);
25 return undefined;
26 }
27};
28
29/**
30 * Fetch Figma image by fileId and nodeId

Callers 1

fetchAndCleanMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected