Hello,
I am working on this Figma plugin and I am using create-figma-plugin toolkit. I want to integrate the plugin with LemonSqueezy’s license key API. I am making a post request and it doesn’t work giving this error:
Error: in fetch: Expected "init.body" to have type Uint8Array but got string instead
at Proxy.fetch (eval at <anonymous> (eval at createScopedEvaluatorFactory (671d607b-e167-4ac8-a492-12b74d724c97:1:6906)), <anonymous>:23:21)
at doit (PLUGIN_1_SOURCE:114:29)
at eval (PLUGIN_1_SOURCE:151:7)
at eval (PLUGIN_1_SOURCE:56:7)
at invokeEventHandler (PLUGIN_1_SOURCE:62:35)
at figma.ui.onmessage (PLUGIN_1_SOURCE:73:11)
at ptr.callFunction (figma_app.min.js.br:717:4755)
at iframeMessageHandler (figma_app.min.js.br:1440:17341)
at EIo.toplevelWindowMessageChannel.port2.onmessage (figma_app.min.js.br:1409:5506)
Here is the code:
try {
const res = await fetch(
'https://api.lemonsqueezy.com/v1/licenses/activate',
{
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/x-www-form-urlencoded',
},
body: 'license_key=38b1460a-5104-4067-a91d-77b872934d51&instance_name=Test',
}
)
const data = await res.json()
console.log(data)
} catch (error) {
console.log(error)
}
The same code works in codesandbox and in a code base using vanilla js.
Any help is appreciated, thanks