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
feat: add static Response.json #1670
Conversation
@@ -124,6 +124,25 @@ export default class Response extends Body { | |||
return response; | |||
} | |||
|
|||
static json(data = undefined, init = {}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node-fetch doesn't seem to do much argument validation, I followed other areas of the code.
For example when constructing a new response:
new Response('', null)
throws an error when it shouldn't
new Response('', 3)
works when it shouldn't (same with booleans, etc)
I'm okey with some small deviations, we don't have all the webidl stuff undici have and don't follow the spec at 100%. it was set up to be "good enough" and solve the most common use cases. it's going to be replaced by NodeJS in the newer versions anyway at some point. node-fetch is just a polyfill at this stage. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! 👍
🎉 This PR is included in version 3.3.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Purpose
Implements static
Response.json
from whatwg/fetch#1392Changes
Adds static Response.json
Additional information