Post

New `baseUrl` option fixes URL handling, `searchParams` option now merges, retries are now more precise by distinguishing failure types, built-in JSON schema validation. Ky is a tiny JS HTTP client built on top of the built-in Fetch.

0 reposts7 likes

baseUrl vs prefix `baseUrl` uses standard URL resolution: `/users` means origin-root, `users` means relative to the base path. `prefix` does simple string joining first, so `/users` and `users` both append to the prefix the same way. Use it only when you want that behavior.

```js // baseUrl ky('users', {baseUrl: '/api/'}) //→ /api/users ky('/users', {baseUrl: '/api/'}) //→ /users (leading slash = origin-root) // prefix ky('users', {prefix: '/api'}) //→ /api/users ky('/users', {prefix: '/api'}) //→ /api/users (leading slash ignored) ```