We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c4ad101 commit b3def2cCopy full SHA for b3def2c
1 file changed
packages/typescript-fetch-runtime/src/common.ts
@@ -38,12 +38,21 @@ export function responseValidationFactoryFactory<Schema>(
38
}
39
40
return new Proxy(res, {
41
- get(target, prop, receiver) {
+ get(target, prop) {
42
if (prop === "json") {
43
return json
44
45
46
- return Reflect.get(target, prop, receiver)
+ const result = Reflect.get(target, prop)
47
+
48
+ // undici does some mixin magic, where it's important that the `this` context
49
+ // is correct, or else it'll fail to access #private properties on the response
50
+ // https://github.com/nodejs/undici/blob/edf9b3ff8bfdf5099826b612d8a55572bb707086/lib/web/fetch/response.js#L310
51
+ if (typeof result === "function") {
52
+ return result.bind(target)
53
+ }
54
55
+ return result
56
},
57
})
58
0 commit comments