Skip to main content
Semi_Design_UED-MED
Jun 29, 2023 3:22 AM UTC
Question

Can I use FormData API in plugin sandbox?

When I use FormData to send a network request to pass a file, I encountered the following error. Can Figma support FormData in sandbox?

fetch API is ok to send file, but it need to change my previous file upload interface.

This topic has been closed for replies.

5 replies

Karl_Koch
Jul 4, 2023 6:56 PM UTC

I’m going to assume you’re attempting to fetch data in code.ts. In this case, you’re trying to access browser APIs in a file that only knows about Figma APIs.

Try moving your logic to your UI file and then pass the response to code.ts via a postMessage.

Semi_Design_UED-MED
Jul 20, 2023 11:56 AM UTC

Thanks you a lot. In dev mode codegen(recent supported by Figma) panel, sandbox can not communicate with ui.

tank666
Jul 20, 2023 2:07 PM UTC

Actually you can. Just call the invisible UI to access the Browser API.

UX/UI designer. Figma expert. Creator and developer of plugins and widgets for Figma and FigJam. Check out my resources in Figma Community: figma.com/@tank
Semi_Design_UED-MED
Jul 24, 2023 3:58 AM UTC

When I called figma.showUI before, there was an error, thank you for your reply, I will try again.

Semi_Design_UED-MED
Jul 26, 2023 1:57 PM UTC

Works!! figma.showUI can pass visible: false.

figma.showUI('xxx', { visible: false });