Skip to content

Commit

Permalink
feat: add support for stringifyJson
Browse files Browse the repository at this point in the history
  • Loading branch information
Reverier-Xu committed Apr 21, 2024
1 parent 210a9b7 commit 5127544
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions readme.md
Expand Up @@ -426,6 +426,29 @@ const json = await ky('https://example.com', {
}).json();
```

##### stringifyJson

Type: `Function`\
Default: `JSON.stringify()`

User-defined JSON-stringifying function.

Use-cases:
1. Stringify JSON with the custom `replacer` function.

```js
import ky from 'ky';
import { DateTime } from 'luxon';
const json = await ky('https://example.com', {
stringifyJson: data => JSON.stringify(data, (_, value) => {
if (value instanceof DateTime) {
return value.toSeconds();
}
return value;
})
}).json();
```

##### fetch

Type: `Function`\
Expand Down

0 comments on commit 5127544

Please sign in to comment.