(resp: Response)
| 54 | } |
| 55 | |
| 56 | async function logResponse(resp: Response) { |
| 57 | console.log("=== FETCH RESPONSE ==="); |
| 58 | console.log(`Status: ${resp.status} ${resp.statusText}`); |
| 59 | console.log("Response Headers:"); |
| 60 | resp.headers.forEach((value, key) => { |
| 61 | console.log(` ${key}: ${value}`); |
| 62 | }); |
| 63 | |
| 64 | // TODO: For streamed responses, this caused the response to be consumed and the connection would just hang open |
| 65 | // Clone response to read body without consuming it |
| 66 | // const respClone = resp.clone(); |
| 67 | // try { |
| 68 | // const responseText = await respClone.text(); |
| 69 | // console.log(`Response Body: ${responseText}`); |
| 70 | // } catch (e) { |
| 71 | // console.log("Could not read response body:", e); |
| 72 | // } |
| 73 | console.log("======================"); |
| 74 | } |
| 75 | |
| 76 | function logError(error: unknown) { |
| 77 | console.log("=== FETCH ERROR ==="); |
no test coverage detected