cloudworker icon indicating copy to clipboard operation
cloudworker copied to clipboard

FormData doesn't exist

Open maple3142 opened this issue 4 years ago • 0 comments

addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request))
})

/**
 * Respond to the request
 * @param {Request} request
 */
async function handleRequest(request) {
  const fd = new FormData()
  return new Response('hello world', {status: 200})
}

This script runs in CloudFlare workers normally, but not in CloudWorker.

But it can be solved by using bindings:

{
	bindings: {
		FormData: require('form-data')
	}
}

maple3142 avatar Aug 20 '20 06:08 maple3142