@whatwg-node/node-fetch 0.4.4-alpha-20230613143421-6ca77f9 → 0.4.4-alpha-20230613145642-e02eaf5
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/cjs/Response.js +8 -9
- package/esm/Response.js +8 -9
- package/package.json +1 -1
package/cjs/Response.js
CHANGED
@@ -59,22 +59,21 @@ class PonyfillResponse extends Body_js_1.PonyfillBody {
|
|
59
59
|
status,
|
60
60
|
});
|
61
61
|
}
|
62
|
-
static json(data, init) {
|
62
|
+
static json(data, init = {}) {
|
63
63
|
let bodyInit = JSON.stringify(data);
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
resInit.headers.set('content-type', JSON_CONTENT_TYPE);
|
64
|
+
if (init.headers != null) {
|
65
|
+
init.headers = new Headers_js_1.PonyfillHeaders(init.headers);
|
66
|
+
if (!init.headers.has('content-type')) {
|
67
|
+
init.headers.set('content-type', JSON_CONTENT_TYPE);
|
69
68
|
}
|
70
|
-
if (!
|
69
|
+
if (!init.headers.has('content-length')) {
|
71
70
|
bodyInit = Buffer.from(bodyInit);
|
72
|
-
|
71
|
+
init.headers.set('content-length', bodyInit.byteLength.toString());
|
73
72
|
}
|
74
73
|
}
|
75
74
|
else {
|
76
75
|
bodyInit = Buffer.from(bodyInit);
|
77
|
-
|
76
|
+
init.headers = [
|
78
77
|
['content-type', JSON_CONTENT_TYPE],
|
79
78
|
['content-length', bodyInit.byteLength.toString()],
|
80
79
|
];
|
package/esm/Response.js
CHANGED
@@ -56,22 +56,21 @@ export class PonyfillResponse extends PonyfillBody {
|
|
56
56
|
status,
|
57
57
|
});
|
58
58
|
}
|
59
|
-
static json(data, init) {
|
59
|
+
static json(data, init = {}) {
|
60
60
|
let bodyInit = JSON.stringify(data);
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
resInit.headers.set('content-type', JSON_CONTENT_TYPE);
|
61
|
+
if (init.headers != null) {
|
62
|
+
init.headers = new PonyfillHeaders(init.headers);
|
63
|
+
if (!init.headers.has('content-type')) {
|
64
|
+
init.headers.set('content-type', JSON_CONTENT_TYPE);
|
66
65
|
}
|
67
|
-
if (!
|
66
|
+
if (!init.headers.has('content-length')) {
|
68
67
|
bodyInit = Buffer.from(bodyInit);
|
69
|
-
|
68
|
+
init.headers.set('content-length', bodyInit.byteLength.toString());
|
70
69
|
}
|
71
70
|
}
|
72
71
|
else {
|
73
72
|
bodyInit = Buffer.from(bodyInit);
|
74
|
-
|
73
|
+
init.headers = [
|
75
74
|
['content-type', JSON_CONTENT_TYPE],
|
76
75
|
['content-length', bodyInit.byteLength.toString()],
|
77
76
|
];
|