Skip to content

Commit adae9a7

Browse files
committed
Readme tweaks
1 parent 762ea4c commit adae9a7

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

readme.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ import ky from 'ky';
7979
const json = await ky.post('https://example.com', {json: {foo: true}}).json();
8080

8181
console.log(json);
82-
//=> `{data: '🦄'}`
82+
//=> {data: '🦄'}
8383
```
8484

8585
With plain `fetch`, it would be:
@@ -102,7 +102,7 @@ if (!response.ok) {
102102
const json = await response.json();
103103

104104
console.log(json);
105-
//=> `{data: '🦄'}`
105+
//=> {data: '🦄'}
106106
```
107107

108108
If you are using [Deno](https://github.com/denoland/deno), import Ky from a URL. For example, using a CDN:
@@ -117,7 +117,7 @@ import ky from 'https://esm.sh/ky';
117117

118118
The `input` and `options` are the same as [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch), with additional `options` available (see below).
119119

120-
Returns a [`Response` object](https://developer.mozilla.org/en-US/docs/Web/API/Response) with [`Body` methods](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#body) added for convenience. So you can, for example, call `ky.get(input).json()` directly without having to await the `Response` first. When called like that, an appropriate `Accept` header will be set depending on the body method used. Unlike the `Body` methods of `window.Fetch`; these will throw an `HTTPError` if the response status is not in the range of `200...299`. Also, `.json()` will return an empty string if body is empty or the response status is `204` instead of throwing a parse error due to an empty body.
120+
Returns a [`Response` object](https://developer.mozilla.org/en-US/docs/Web/API/Response) with [`Body` methods](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#body) added for convenience. So you can, for example, call `ky.get(input).json()` directly without having to await the `Response` first. When called like that, an appropriate `Accept` header will be set depending on the body method used. Unlike the `Body` methods of `window.Fetch`, these will throw an `HTTPError` if the response status is not in the range of `200...299`. Also, `.json()` will return an empty string if body is empty or the response status is `204` instead of throwing a parse error due to an empty body.
121121

122122
```js
123123
import ky from 'ky';
@@ -673,7 +673,7 @@ const json = await ky.post('https://example.com', {
673673
}).json();
674674

675675
console.log(json);
676-
//=> `{data: '🦄'}`
676+
//=> {data: '🦄'}
677677
```
678678

679679
### Cancellation
@@ -761,11 +761,10 @@ Node.js 18 and later.
761761
## Related
762762

763763
- [fetch-extras](https://github.com/sindresorhus/fetch-extras) - Useful utilities for working with Fetch
764-
- [got](https://github.com/sindresorhus/got) - Simplified HTTP requests for Node.js
765764
- [ky-hooks-change-case](https://github.com/alice-health/ky-hooks-change-case) - Ky hooks to modify cases on requests and responses of objects
766765

767766
## Maintainers
768767

769768
- [Sindre Sorhus](https://github.com/sindresorhus)
770-
- [Szymon Marczak](https://github.com/szmarczak)
771769
- [Seth Holladay](https://github.com/sholladay)
770+
- [Szymon Marczak](https://github.com/szmarczak)

0 commit comments

Comments
 (0)