kwhitley / itty-fetcher

An even simpler wrapper around native Fetch to strip boilerplate from your fetching code!
MIT License
99 stars 4 forks source link

FormData is not defined #16

Closed kwhitley closed 2 years ago

kwhitley commented 2 years ago

image

Environment: fetching through SvelteKit +server.js endpoints

Crisfole commented 2 years ago

SvelteKit provides a FormData...

https://kit.svelte.dev/docs/form-actions#anatomy-of-an-action

What do you get when you do:

const fd = await request.formData()
console.log(fd);
console.log(typeof fd);
console.log(fd.__prototype);
return { ...fd, FORM_DATA_TYPE: typeof fd, FULL_FD: fd };
Crisfole commented 2 years ago

https://github.com/sveltejs/kit/blob/c1ee512fdb3bce2702f72f1818dc25bef581f647/packages/kit/src/exports/node/polyfills.js

Here's where they (theoretically) perform the polyfill.

https://github.com/sveltejs/kit/blob/c1ee512fdb3bce2702f72f1818dc25bef581f647/packages/kit/src/exports/vite/dev/index.js#L31

There's where during dev they call 'installPolyfills'...

danawoodman commented 2 years ago

Weird, I don't see those issues in SK, lemme see if I can repro

Crisfole commented 2 years ago

@kwhitley What adapter are you using there?

danawoodman commented 2 years ago

Yeah if you're using the node adapter you'll need 18+