//native
type Figma = {
token: string;
};
/**
* Add a reaction to a comment
* Posts a new comment reaction on a file comment.
*/
export async function main(
auth: Figma,
file_key: string,
comment_id: string,
body: { emoji: string },
) {
const url = new URL(
`https://api.figma.com/v1/files/${file_key}/comments/${comment_id}/reactions`,
);
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