ky
ky copied to clipboard
feat: add support for `stringifyJson`
When sending an HTTP request, this option allows the user to specify how the request data should be serialized as a string.
For example, it will be useful when users want to change the default serialization behavior using JSON.stringify(_, replacer)
.
import ky from 'ky';
import { DateTime } from 'luxon';
const json = await ky('https://example.com', {
stringifyJson: data => JSON.stringify(data, (key, value) => {
if (key.endsWith('_at')) {
return DateTime.fromISO(value).toSeconds();
}
return value;
})
}).json();