Hi Folks,
I am trying to use the figma comment API inside the plugin but not able to call that directly, I tried to use Axios also but getting errors.
Can we call figma apis directly inside plugin, is it possible? below code I am trying to execute.
fetch('https://api.figma.com/v1/files/R6ykujiQzXipdL2KxEUX1a/comments', {
method: 'GET',
mode: 'cors',
cache: 'no-cache',
headers: {
'Content-Type': 'application/json',
'X-FIGMA-TOKEN': 'figd_mfT5pS4cf62EMIfsxlIWZjF4XNsmo8Se19V',
},
}).then(resp => resp.json() // this returns a promise
).then(repos => {
let csvContent = "data:text/csv;charset=utf-8,";
for (const repo of repos.comments) {
let row = '';
for (const property in repo) {
if (typeof repo[property] == 'string')
row += repo[property]+ ",";
}
csvContent += row + "\r\n";
}
var encodedUri = encodeURI(csvContent);
window.open(encodedUri);
}).catch(ex => {
});
Here I want to download the comments on current figma page by running the plugin.