()
| 110 | } |
| 111 | |
| 112 | async json(): Promise<any> { |
| 113 | if (this.bodyUsed) throw new TypeError("Body already consumed"); |
| 114 | (this as any).bodyUsed = true; |
| 115 | if (!this.#bytes) return null; |
| 116 | const text = new TextDecoder().decode(this.#bytes); |
| 117 | try { |
| 118 | return JSON.parse(text); |
| 119 | } catch { |
| 120 | throw new SyntaxError("Invalid JSON"); |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | async text(): Promise<string> { |
| 125 | if (this.bodyUsed) throw new TypeError("Body already consumed"); |
no test coverage detected