@whatwg-node/fetch 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @whatwg-node/fetch
2
2
 
3
+ ## 0.4.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`c9f05f2`](https://github.com/ardatan/whatwg-node/commit/c9f05f21fb96f63bc22359e3b7981cb9b3b727b5) Thanks [@ardatan](https://github.com/ardatan)! - Add ponyfills for Response.redirect, Response.json and Response.error
8
+
3
9
  ## 0.4.2
4
10
 
5
11
  ### Patch Changes
@@ -319,5 +319,34 @@ module.exports = function createNodePonyfill(opts = {}) {
319
319
 
320
320
  }
321
321
  }
322
+
323
+ if (!ponyfills.Response.redirect) {
324
+ ponyfills.Response.redirect = function (url, status = 302) {
325
+ return new ponyfills.Response(null, {
326
+ status,
327
+ headers: {
328
+ Location: url,
329
+ },
330
+ });
331
+ };
332
+ }
333
+ if (!ponyfills.Response.json) {
334
+ ponyfills.Response.json = function (data, init = {}) {
335
+ return new ponyfills.Response(JSON.stringify(data), {
336
+ ...init,
337
+ headers: {
338
+ "Content-Type": "application/json",
339
+ ...init.headers,
340
+ },
341
+ });
342
+ };
343
+ }
344
+ if (!ponyfills.Response.error) {
345
+ ponyfills.Response.error = function () {
346
+ return new ponyfills.Response(null, {
347
+ status: 500,
348
+ });
349
+ };
350
+ }
322
351
  return ponyfills;
323
352
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatwg-node/fetch",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Cross Platform Smart Fetch Ponyfill",
5
5
  "author": "Arda TANRIKULU <ardatanrikulu@gmail.com>",
6
6
  "repository": {