Figma Support Forum

Cannot api calls without iframe?

I tried to make api call with axios inside main plugin file.
but It seems not work and it’s very annoying.

Relevant page from the docs:

but it seems like I am only able to make a network request if I run figma.ui.postMessage({ type: 'networkRequest' }); directly in the main thread. It doesn’t work anywhere else. Making a XMLHttpRequest in a onclick callback also doesn’t work. It’s not that useful if I can’t make a network request when the user clicks a button in the plugin window. Any solution?

You don’t need that part if you want to make a request when the user clicks a button. Just do it the normal JS way.