(url, info)
| 16 | import { URLSearchParams } from "url"; |
| 17 | |
| 18 | async function readData(url, info) { |
| 19 | try { |
| 20 | const response = await fetch(url, info); |
| 21 | const transformedBody = response.body.pipeThrough(new TextDecoderStream()); |
| 22 | |
| 23 | const reader = transformedBody.getReader(); |
| 24 | while (true) { |
| 25 | const { done, value } = await reader.read(); |
| 26 | if (value) { |
| 27 | trace(value); |
| 28 | } |
| 29 | if (done) { |
| 30 | trace("\n"); |
| 31 | return; |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | catch(e) { |
| 36 | trace(`${e}\n`); |
| 37 | } |
| 38 | } |
| 39 | let controller = new AbortController(); |
| 40 | readData("http://httpbin.org/encoding/utf8", { signal: controller.signal }); |
| 41 |
no test coverage detected