Allow modifications cases on requests and responses of the objects during the ky request
$ npm install @alice-health/ky-hooks-change-case
import ky from "ky";
import {
requestToSnakeCase,
responseToCamelCase,
} from "@alice-health/ky-hooks-change-case";
ky.post(`${server.url}/path`, {
json: { fooBar: true },
hooks: {
beforeRequest: [requestToSnakeCase],
afterResponse: [responseToCamelCase],
},
});In the example above, the requestToSnakeCase method will convert the resquest body from {fooBar: true} to {foo_bar: true} and the response from {response_body: false} to {responseBody: false}. This way, the frontend and the backend API can each define their independent style guide.
Convert the request body keys objects to snake_case.
Convert the request body keys objects to camelCase.
Convert the request body keys objects to kebab-case.
Convert the response body keys objects to snake_case.
Convert the response body keys objects to camelCase.
Convert the response body keys objects to kebab-case.
The latest version of Chrome, Firefox, and Safari.
ky 🌳 Tiny & elegant HTTP client based on window.fetch