What are the alternatives for sending a POST request with form-data when FormData is not an option? (Airtable scripts)

In the context of using the Cloudinary API, I need to send data formatted as multipart/form-data. However, I’m in a situation where FormData is not accessible. What alternatives can I consider for achieving that? Here’s a basic example of what I would use if FormData were available:

const dataToSend = new FormData();
dataToSend.append('image', assetUrl);
dataToSend.append('preset', CLOUDINARY_UNSIGNED_UPLOAD_PRESET);
dataToSend.append('name', CLOUDINARY_CLOUD_NAME);

console.log(`Starting upload (id: ${id}) to Cloudinary`, CLOUDINARY_UPLOAD_URL, dataToSend);
const result = await fetch(CLOUDINARY_UPLOAD_URL, {
  method: 'POST',
  body: dataToSend,
});

I’ve experimented with various methods, but it appears that the Cloudinary API is quite particular and only accepts data sent in the multipart/form-data format.

you can use the ‘axios’ library with the ‘form-data’ package. They workd together well for sending multipart/form. create a FormData object, append your data & pass it to axios.post. make sure to include required headers for form-data, it should do the trick!