//native
type Figma = {
token: string;
};
/**
* Get reactions for a comment
* Gets a paginated list of reactions left on the comment.
*/
export async function main(
auth: Figma,
file_key: string,
comment_id: string,
cursor: string | undefined,
) {
const url = new URL(
`https://api.figma.com/v1/files/${file_key}/comments/${comment_id}/reactions`,
);
for (const [k, v] of [["cursor", cursor]]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago