1 | /**
|
2 | Returns a `Response` object with `Body` methods added for convenience. So you can, for example, call `ky.get(input).json()` directly without having to await the `Response` first. When called like that, an appropriate `Accept` header will be set depending on the body method used. Unlike the `Body` methods of `window.Fetch`; these will throw an `HTTPError` if the response status is not in the range of `200...299`. Also, `.json()` will return an empty string if the response status is `204` instead of throwing a parse error due to an empty body.
|
3 | */
|
4 | export interface ResponsePromise extends Promise<Response> {
|
5 | arrayBuffer: () => Promise<ArrayBuffer>;
|
6 | blob: () => Promise<Blob>;
|
7 | formData: () => Promise<FormData>;
|
8 | /**
|
9 | Get the response body as JSON.
|
10 |
|
11 | @example
|
12 | ```
|
13 | import ky from 'ky';
|
14 |
|
15 | const json = await ky(…).json();
|
16 | ```
|
17 |
|
18 | @example
|
19 | ```
|
20 | import ky from 'ky';
|
21 |
|
22 | interface Result {
|
23 | value: number;
|
24 | }
|
25 |
|
26 | const result = await ky(…).json<Result>();
|
27 | ```
|
28 | */
|
29 | json: <T = unknown>() => Promise<T>;
|
30 | text: () => Promise<string>;
|
31 | }
|