Skip to content

Commit

Permalink
fix the example of stringifyJson in doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Reverier-Xu committed Apr 21, 2024
1 parent 5127544 commit 1e1e476
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions readme.md
Expand Up @@ -440,9 +440,9 @@ Use-cases:
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();
stringifyJson: data => JSON.stringify(data, (key, value) => {
if (key.endsWith('_at')) {
return DateTime.fromISO(value).toSeconds();
}
return value;
})
Expand Down
6 changes: 3 additions & 3 deletions source/types/options.ts
Expand Up @@ -72,9 +72,9 @@ export type KyOptions = {
import { DateTime } from 'luxon';
const json = await ky('https://example.com', {
stringifyJson: data => JSON.stringify(data, (_, value) => {
if (value instanceof DateTime) {
return value.toSeconds();
stringifyJson: data => JSON.stringify(data, (key, value) => {
if (key.endsWith('_at')) {
return DateTime.fromISO(value).toSeconds();
}
return value;
Expand Down

0 comments on commit 1e1e476

Please sign in to comment.