Options
Options are the same as window.fetch
, except for the KyOptions
interface Options extends KyOptions, Omit<RequestInit, "headers"> {
headers?: KyHeadersInit;
method?: LiteralUnion<HttpMethod, string>;
}§Properties
§
headers?: KyHeadersInit
[src]HTTP headers used to make the request.
You can pass a `Headers` instance or a plain object.
You can remove a header with `.extend()` by passing the header with an `undefined` value.
@example
import ky from 'ky';
const url = 'https://sindresorhus.com';
const original = ky.create({
headers: {
rainbow: 'rainbow',
unicorn: 'unicorn'
}
});
const extended = original.extend({
headers: {
rainbow: undefined
}
});
const response = await extended(url).json();
console.log('rainbow' in response);
//=> false
console.log('unicorn' in response);
//=> true
```