//native
type Figma = {
token: string;
};
/**
* Create dev resources
* Bulk create dev resources across multiple files.
*/
export async function main(
auth: Figma,
body: {
dev_resources: {
name: string;
url: string;
file_key: string;
node_id: string;
}[];
},
) {
const url = new URL(`https://api.figma.com/v1/dev_resources`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago