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.
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