UNPKG

ketting

Version:

Opiniated HATEAOS / Rest client.

40 lines (39 loc) 1.29 kB
/// <reference types="node" /> export declare type HttpHeaders = Record<string, string>; /** * RequestOptions is a set of properties that define * a request, or state change. * * Everything is usually optional. */ export declare type RequestOptions<T = any> = { /** * Should return a string or a Buffer. * * Will be used as the body in the HTTP request. * If not set, `body` will be used instead. */ serializeBody?: () => string | Buffer | Blob; /** * If set, contains the body of the current state. * * If body is not a `string` or a `Buffer`, the body will * be json encoded. */ data?: T; /** * List of headers that will be set in the request. * * If this is not set, we'll fall back to 'headers' */ getContentHeaders?: () => HttpHeaders | Headers; /** * Full list of HTTP headers. */ headers?: HttpHeaders | Headers; }; export declare type GetRequestOptions = Omit<RequestOptions, 'serializeBody' | 'data'>; export declare type HeadRequestOptions = GetRequestOptions; export declare type PatchRequestOptions<T = any> = RequestOptions<T>; export declare type PutRequestOptions<T = any> = RequestOptions<T>; export declare type PostRequestOptions<T = any> = RequestOptions<T>;