| 192 | // } |
| 193 | |
| 194 | const parseJsonResponse = async (response: Response): Promise<any> => { |
| 195 | const text = await response.text() |
| 196 | const isSuperjson = response.headers.get("x-is-superjson") === "true" |
| 197 | |
| 198 | try { |
| 199 | return isSuperjson ? superjson.parse(text) : JSON.parse(text) |
| 200 | } catch (error) { |
| 201 | console.error("Failed to parse response as JSON:", error) |
| 202 | throw new Error("Invalid JSON response") |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | function serializeWithSuperJSON(data: any): any { |
| 207 | if (typeof data !== "object" || data === null) { |