Fix: support FormData
object on fetch body
#3417
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
node-fetch
to external dependency for@astrojs/webapi
bundle. This was causing strange issues with body parsing that I still haven't figured out. Still, since@astrojs/telemetry
already pulls innode-fetch
as a standard dependency, this shouldn't be a problem!node-fetch/src/index.js
exposed type issues. A few pieces to resolve:fetch
no longer acceptsURL
as a resource type. Funny enough, you can still pass aURL
for node-fetch to runtoString()
implicitly. Still, you get red squigglies in VS Code using URL today, so removing this type option is for consistency if anything.FetchInit
now uses node-fetch's body type in its type signatureWhy not switch to undici like all the cool kids?
@FredKSchott (a cool kid) suggested using undici since it mirrors Node's incoming fetch standard. This seemed possible at first... until I discovered their node versioning requirements. In short: they don't expose
fetch
orRequest
for node versions below 16.5. Also poked the source code to confirm. This would mean dropping Node 14.X support, which feels a bit too far as we approach 1.0. Keep it in mind for the future though!Testing
N/A
Docs
N/A