-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 BUG: FormData object causes fetch error #2741
Comments
We should update from node-fetch to https://www.npmjs.com/package/undici, which is becoming the official |
@FredKSchott Interesting! Will say I'm hitting some snags in a local setup though:
---
// even re-cast to `undiciFetch` to see if our compiler was getting clever
import {fetch as undiciFetch, FormData} from 'undici'
const title = "Demo"
const formData = new FormData()
formData.set('title', title)
await undiciFetch('https://example.com', {
method: 'POST',
body: formData,
headers: {
'Content-Type': 'application/json',
}
})
--- I see the server error: 05:36:55 PM [error] TypeError: __vite_ssr_import_1__.fetch is not a function
at eval (/Users/benholmes/Sandbox/form-plz/src/pages/index.astro:19:31)
at renderToString (file:///Users/benholmes/Sandbox/form-plz/node_modules/.pnpm/astro@0.24.3/node_modules/astro/dist/runtime/server/index.js:334:27)
at render (file:///Users/benholmes/Sandbox/form-plz/node_modules/.pnpm/astro@0.24.3/node_modules/astro/dist/core/render/core.js:85:20)
at async render (file:///Users/benholmes/Sandbox/form-plz/node_modules/.pnpm/astro@0.24.3/node_modules/astro/dist/core/render/dev/index.js:50:17)
at async ssr (file:///Users/benholmes/Sandbox/form-plz/node_modules/.pnpm/astro@0.24.3/node_modules/astro/dist/core/render/dev/index.js:118:12)
at async handleRequest (file:///Users/benholmes/Sandbox/form-plz/node_modules/.pnpm/astro@0.24.3/node_modules/astro/dist/vite-plugin-astro-server/index.js:115:18) |
Oh, I meant to say to update it in the |
What version of
astro
are you using?0.23.7
What package manager are you using?
npm, pnpm
What operating system are you using?
Mac
Describe the Bug
FormData
object in any.astro
templatePOST
request withFormData
as the requestbody
Example:
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-ypljcj-82rtfc?file=src/pages/index.astro
The text was updated successfully, but these errors were encountered: