Cannot make a POST request in figma plugin

Hi there :slight_smile:

I am trying to execute a POST request.
I already succeed with GET request with fetch method (from typescript lib) but I tried a lot of alternatives (axios, node-fetch) to make a POST request without succeed.

So I come back to the basics from the figma documentation and trying to do my request like that:

var request = new XMLHttpRequest()
  request.open('POST', url)
  request.responseType = 'text'
  request.setRequestHeader('Content-Type', 'application/json')
  request.setRequestHeader('Authorization', 'Bearer XXX')
  request.setRequestHeader('Access-Control-Allow-Origin', '*')

  request.onload = () => {
    console.log("request.response  " + request.response)
    window.parent.postMessage({ pluginMessage: request.response }, '*')
  };
  request.send()

I have this error:

Uncaught (in promise) TypeError: XMLHttpRequest is not a constructor

I am building my figma plugin with webpack and typescript

Do you have any ideas? Thanks in advance :slight_smile: