Skip to content

Commit 077d7b0

Browse files
authored
docs: make examples uniform (nodejs#1647)
1 parent 2903bc1 commit 077d7b0

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,12 @@ Help us improve the test coverage by following instructions at [nodejs/undici/#9
185185
Basic usage example:
186186

187187
```js
188-
import { fetch } from 'undici';
188+
import { fetch } from 'undici'
189189

190190

191191
const res = await fetch('https://example.com')
192192
const json = await res.json()
193-
console.log(json);
193+
console.log(json)
194194
```
195195

196196
You can pass an optional dispatcher to `fetch` as:
@@ -225,29 +225,29 @@ A body can be of the following types:
225225
In this implementation of fetch, ```request.body``` now accepts ```Async Iterables```. It is not present in the [Fetch Standard.](https://fetch.spec.whatwg.org)
226226

227227
```js
228-
import { fetch } from "undici";
228+
import { fetch } from 'undici'
229229

230230
const data = {
231231
async *[Symbol.asyncIterator]() {
232-
yield "hello";
233-
yield "world";
232+
yield 'hello'
233+
yield 'world'
234234
},
235-
};
235+
}
236236

237-
await fetch("https://example.com", { body: data, method: 'POST' });
237+
await fetch('https://example.com', { body: data, method: 'POST' })
238238
```
239239

240240
#### `response.body`
241241

242242
Nodejs has two kinds of streams: [web streams](https://nodejs.org/dist/latest-v16.x/docs/api/webstreams.html), which follow the API of the WHATWG web standard found in browsers, and an older Node-specific [streams API](https://nodejs.org/api/stream.html). `response.body` returns a readable web stream. If you would prefer to work with a Node stream you can convert a web stream using `.fromWeb()`.
243243

244244
```js
245-
import { fetch } from 'undici';
246-
import { Readable } from 'node:stream';
245+
import { fetch } from 'undici'
246+
import { Readable } from 'node:stream'
247247

248248
const response = await fetch('https://example.com')
249-
const readableWebStream = response.body;
250-
const readableNodeStream = Readable.fromWeb(readableWebStream);
249+
const readableWebStream = response.body
250+
const readableNodeStream = Readable.fromWeb(readableWebStream)
251251
```
252252

253253
#### Specification Compliance

0 commit comments

Comments
 (0)