API
Index
Enumerations
BodyCasing
ContentType
HttpCode
HttpMethod
ParsedBodyCacheState
Classes
CFormData
HttpClient
HttpRequestError
HttpResponseError
HttpResponseHeaders
Interfaces
BodyParserOptions
BodySerializerOptions
CFormDataEntryMetadata
CFormDataEntryValue
Endpoint
FetchRequestHandlerOptions
FormDataFromOptions
HttpClientConfig
HttpInterceptorInterface
HttpRequestHandlerOptions
HttpRequestOptions
HttpResponse
HttpResponseOptions
Log
LoggingInterceptorOptions
MockOptions
NormalizedHttpOptions
RawHttpResponse
RedirectionInterceptorOptions
SimpleServer
XhrRequestHandlerOptions
Type aliases
Variables
Functions
Object literals
Type aliases
BodyParser
Ƭ BodyParser: function
Type declaration:
▸ (response
: RawHttpResponse): HttpResponse‹T›
Parameters:
Name | Type |
---|---|
| RawHttpResponse |
BodyParserImplementation
Ƭ BodyParserImplementation: function
Type declaration:
▸ (rawResponse
: RawHttpResponse): Promise‹any›
Parameters:
Name | Type |
---|---|
| RawHttpResponse |
BodySerializer
Ƭ BodySerializer: function
Type declaration:
▸ (request
: HttpOptions): NormalizedHttpBody
Parameters:
Name | Type |
---|---|
|
BufferEncoding
Ƭ BufferEncoding: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex"
CFormDataValue
Ƭ CFormDataValue: string | Blob | Readable
CaseConverter
Ƭ CaseConverter: function
Type declaration:
▸ (object
: any): any
Parameters:
Name | Type |
---|---|
| any |
ContentTypeMap
Ƭ ContentTypeMap: Record‹keyof typeof ContentTypeRegex, T›
HttpBody
Ƭ HttpBody: object | TypedArray | string
HttpFetch
Ƭ HttpFetch: function
Type declaration:
▸ (): Promise‹HttpResponse‹Body››
HttpHeaders
Ƭ HttpHeaders: Record‹string, string | number | boolean | undefined | null›
HttpInterceptor
Ƭ HttpInterceptor: HttpInterceptorFunction | HttpInterceptorInterface
HttpInterceptorFunction
Ƭ HttpInterceptorFunction: function
Type declaration:
▸ <Body>(request
: HttpFetch‹Body›, options
: NormalizedHttpOptions): HttpFetch‹Body›
Type parameters:
▪ Body
Parameters:
Name | Type |
---|---|
| HttpFetch‹Body› |
| NormalizedHttpOptions |
HttpOptions
Ƭ HttpOptions: Partial‹HttpRequestOptions›
HttpRequestHandler
Ƭ HttpRequestHandler: function
Type declaration:
▸ (requestOptions
: NormalizedHttpOptions): Promise‹RawHttpResponse›
Parameters:
Name | Type |
---|---|
| NormalizedHttpOptions |
MockHttpRequestHandler
Ƭ MockHttpRequestHandler: HttpRequestHandler & object
NormalizedHttpBody
Ƭ NormalizedHttpBody: FormData | CFormData | TypedArray | string | undefined
PromiseFunction
Ƭ PromiseFunction: function
Type declaration:
▸ (): Promise‹T›
RequestMode
Ƭ RequestMode: "navigate" | "same-origin" | "no-cors" | "cors"
Variables
Const
DEFAULT_REQUEST_TIMEOUT_MS
Const
DEFAULT_REQUEST_TIMEOUT_MS• DEFAULT_REQUEST_TIMEOUT_MS: number = 5 * 60 * 1000
Default request timeout - 5 minutes.
Const
DONE
Const
DONE• DONE: 4 = 4
Const
HEADERS_RECEIVED
Const
HEADERS_RECEIVED• HEADERS_RECEIVED: 2 = 2
Const
SUPPORTS_BROWSER_FORM_DATA
Const
SUPPORTS_BROWSER_FORM_DATA• SUPPORTS_BROWSER_FORM_DATA: boolean = (() => { try { return !({} instanceof FormData); } catch { return false; } })()
TypedArray
• TypedArray: any
Const
symbol
Const
symbol• symbol: unique symbol = Symbol('HttpResponseError')
Functions
Const
bodyParser
Const
bodyParser▸ bodyParser(__namedParameters
: object): BodyParser‹any›
Parameters:
▪Default value
__namedParameters: object= {}
Name | Type |
---|---|
| undefined | CAMEL_CASE | SNAKE_CASE | SCREAMING_SNAKE_CASE | PASCAL_CASE | KEBAB_CASE |
| undefined | function |
|
Returns: BodyParser‹any›
Const
bodySerializer
Const
bodySerializer▸ bodySerializer(__namedParameters
: object): BodySerializer
Parameters:
▪Default value
__namedParameters: object= {}
Name | Type |
---|---|
| undefined | CAMEL_CASE | SNAKE_CASE | SCREAMING_SNAKE_CASE | PASCAL_CASE | KEBAB_CASE |
Returns: BodySerializer
Const
cacheParsedBody
Const
cacheParsedBody▸ cacheParsedBody<T>(parsedBody
: PromiseFunction‹T›): PromiseFunction‹T›
This is not a regular cache! This function is only used across subsequent executions of parsedBody() on a single HttpResponse. To implement cache, make use of interceptors.
Type parameters:
▪ T
Parameters:
Name | Type | Description |
---|---|---|
| a promise function returning parsed body, which in most cases can be called only once |
Returns: PromiseFunction‹T›
a promise function returning body, it can be called many times
Const
createAsyncBodyHandler
Const
createAsyncBodyHandler▸ createAsyncBodyHandler<T>(): object
Type parameters:
▪ T
Returns: object
call(): Promise‹T›
onBodyFailure(
failer
: function): voidonBodyReceived(
getter
: function): void
Const
createErrorInterceptor
Const
createErrorInterceptor▸ createErrorInterceptor(): HttpInterceptorFunction
Returns: HttpInterceptorFunction
Const
createHttpResponse
Const
createHttpResponse▸ createHttpResponse(__namedParameters
: object): HttpResponse
Parameters:
▪ __namedParameters: object
Name | Type | Default |
---|---|---|
| undefined | string | Uint8Array‹› | Uint8ClampedArray‹› | Uint16Array‹› | Uint32Array‹› | Int8Array‹› | Int16Array‹› | Int32Array‹› | Float32Array‹› | Float64Array‹› | - |
| BodyParserOptions | - |
| undefined | object | - |
| number | - |
| string | "" |
Returns: HttpResponse
Const
createLoggingInterceptor
Const
createLoggingInterceptor▸ createLoggingInterceptor(__namedParameters
: object): HttpInterceptorFunction
Parameters:
▪ __namedParameters: object
Name | Type |
---|---|
| function |
Returns: HttpInterceptorFunction
Const
createRedirectionInterceptor
Const
createRedirectionInterceptor▸ createRedirectionInterceptor(__namedParameters
: object): HttpInterceptorFunction
Parameters:
▪Default value
__namedParameters: object= {}
Name | Type | Default |
---|---|---|
| number | 30 |
Returns: HttpInterceptorFunction
Const
createSimpleServer
Const
createSimpleServer▸ createSimpleServer(): SimpleServer
Returns: SimpleServer
Const
deepKeyMap
Const
deepKeyMap▸ deepKeyMap(object
: any, mapper
: function): any
Parameters:
▪ object: any
▪ mapper: function
▸ (key
: string): string
Parameters:
Name | Type |
---|---|
| string |
Returns: any
Const
defaultHeaders
Const
defaultHeaders▸ defaultHeaders(_host
: string): object
Parameters:
Name | Type | Default |
---|---|---|
| string | "" |
Returns: object
Accept: string = "application/json,application/vnd.api+json"
Content-Type: ContentType = ContentType.JSON
Const
encodeArrayBuffer
Const
encodeArrayBuffer▸ encodeArrayBuffer(data
: TypedArray | string | undefined, encoding
: BufferEncoding): Uint8Array‹›
Parameters:
Name | Type | Default |
---|---|---|
| TypedArray | string | undefined | "" |
| "utf8" |
Returns: Uint8Array‹›
Const
encodeText
Const
encodeText▸ encodeText(buffer
: ArrayBuffer, encoding
: string): string
Parameters:
Name | Type | Default |
---|---|---|
| ArrayBuffer | - |
| string | "utf8" |
Returns: string
Const
fetchRequestHandler
Const
fetchRequestHandler▸ fetchRequestHandler(fetchRequestHandlerOptions
: FetchRequestHandlerOptions): HttpRequestHandler
Creates a new HttpRequestHandler that uses Fetch API underneath. Does not support timeout property. Abort is possible only after headers were received.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
| FetchRequestHandlerOptions | {} | default Fetch API options attached to all requests |
Returns: HttpRequestHandler
Const
getBoundaryFromContentTypeHeader
Const
getBoundaryFromContentTypeHeader▸ getBoundaryFromContentTypeHeader(header
: string[]): string
Parameters:
Name | Type |
---|---|
| string[] |
Returns: string
Const
getCaseConverter
Const
getCaseConverter▸ getCaseConverter(bodyCasing?
: BodyCasing): toCamelCase
Parameters:
Name | Type |
---|---|
| BodyCasing |
Returns: toCamelCase
Const
getEncodingFromHeaders
Const
getEncodingFromHeaders▸ getEncodingFromHeaders(headers
: HttpResponseHeaders | undefined, fallback
: string): string
Parameters:
Name | Type | Default |
---|---|---|
| HttpResponseHeaders | undefined | - |
| string | "utf8" |
Returns: string
Const
getFileMeta
Const
getFileMeta▸ getFileMeta(value
: Blob | Readable, existingMeta?
: CFormDataEntryMetadata): object | object
Parameters:
Name | Type |
---|---|
| Blob | Readable |
| CFormDataEntryMetadata |
Returns: object | object
Const
getHeader
Const
getHeader▸ getHeader(headers
: HttpHeaders | undefined, header
: string): string | undefined
Parameters:
Name | Type |
---|---|
| HttpHeaders | undefined |
| string |
Returns: string | undefined
Const
getHostname
Const
getHostname▸ getHostname(url
: string): string
Parameters:
Name | Type |
---|---|
| string |
Returns: string
Const
handleRequest
Const
handleRequest▸ handleRequest(code
: number, body
: any, contentType
: string): Promise‹HttpResponse›
Parameters:
Name | Type | Default |
---|---|---|
| number | - |
| any | - |
| string | ContentType.TEXT |
Returns: Promise‹HttpResponse›
Const
httpRequestHandler
Const
httpRequestHandler▸ httpRequestHandler(requestHandlerOptions
: HttpRequestHandlerOptions): HttpRequestHandler
Creates a new HttpRequestHandler that uses native Node.js HTTP & HTTPS modules underneath. Does not support mode property.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
| HttpRequestHandlerOptions | {} | default native options attached to all requests |
Returns: HttpRequestHandler
Const
isBlob
Const
isBlob▸ isBlob(value
: any): value is Blob
Parameters:
Name | Type |
---|---|
| any |
Returns: value is Blob
Const
isBrowserFormData
Const
isBrowserFormData▸ isBrowserFormData(value
: any): value is FormData
Parameters:
Name | Type |
---|---|
| any |
Returns: value is FormData
Const
isHttpInterceptorInterface
Const
isHttpInterceptorInterface▸ isHttpInterceptorInterface(interceptor
: HttpInterceptor): interceptor is HttpInterceptorInterface
Parameters:
Name | Type |
---|---|
|
Returns: interceptor is HttpInterceptorInterface
Const
isHttpRequestError
Const
isHttpRequestError▸ isHttpRequestError(error
: any): error is HttpRequestError
Parameters:
Name | Type |
---|---|
| any |
Returns: error is HttpRequestError
Const
isHttpResponseError
Const
isHttpResponseError▸ isHttpResponseError(error
: any): error is HttpResponseError
Parameters:
Name | Type |
---|---|
| any |
Returns: error is HttpResponseError
Const
mockRequestHandler
Const
mockRequestHandler▸ mockRequestHandler(mockOptions
: MockOptions): MockHttpRequestHandler
Parameters:
Name | Type |
---|---|
| MockOptions |
Returns: MockHttpRequestHandler
Const
noConversion
Const
noConversion▸ noConversion(object
: any): any
Parameters:
Name | Type |
---|---|
| any |
Returns: any
Const
parseHeaders
Const
parseHeaders▸ parseHeaders(headers
: Headers): Record‹string, string›
Parameters:
Name | Type |
---|---|
| Headers |
Returns: Record‹string, string›
Const
processMultipartBody
Const
processMultipartBody▸ processMultipartBody(body
: string, boundary
: string): never
Parameters:
Name | Type |
---|---|
| string |
| string |
Returns: never
Const
readBlob
Const
readBlob▸ readBlob(blob
: Blob): Promise‹Buffer›
Parameters:
Name | Type |
---|---|
| Blob |
Returns: Promise‹Buffer›
Const
sanitizeHeaders
Const
sanitizeHeaders▸ sanitizeHeaders(...multipleHeaders
: undefined | object[]): Record‹string, string›
Parameters:
Name | Type |
---|---|
| undefined | object[] |
Returns: Record‹string, string›
Const
sleep
Const
sleep▸ sleep(ms
: number): Promise‹unknown›
Parameters:
Name | Type |
---|---|
| number |
Returns: Promise‹unknown›
Const
splitWords
Const
splitWords▸ splitWords(text
: string): string[]
Parameters:
Name | Type |
---|---|
| string |
Returns: string[]
switchContentType
▸ switchContentType<T>(contentType
: string, map
: ContentTypeMap‹T›, defaultResult
: T): T
Type parameters:
▪ T
Parameters:
Name | Type |
---|---|
| string |
| |
| T |
Returns: T
▸ switchContentType<T>(contentType
: string, map
: ContentTypeMap‹T›): T | undefined
Type parameters:
▪ T
Parameters:
Name | Type |
---|---|
| string |
|
Returns: T | undefined
Const
toCamelCase
Const
toCamelCase▸ toCamelCase(object
: any): any
Parameters:
Name | Type |
---|---|
| any |
Returns: any
Const
toKebabCase
Const
toKebabCase▸ toKebabCase(object
: any): any
Parameters:
Name | Type |
---|---|
| any |
Returns: any
Const
toPascalCase
Const
toPascalCase▸ toPascalCase(object
: any): any
Parameters:
Name | Type |
---|---|
| any |
Returns: any
Const
toScreamingSnakeCase
Const
toScreamingSnakeCase▸ toScreamingSnakeCase(object
: any): any
Parameters:
Name | Type |
---|---|
| any |
Returns: any
Const
toSnakeCase
Const
toSnakeCase▸ toSnakeCase(object
: any): any
Parameters:
Name | Type |
---|---|
| any |
Returns: any
Const
toUrlEncoded
Const
toUrlEncoded▸ toUrlEncoded(obj
: object): string
Parameters:
Name | Type |
---|---|
| object |
Returns: string
Const
urlCombine
Const
urlCombine▸ urlCombine(sourceUrl
: string, sourceQuery?
: undefined | object, options?
: qs.IStringifyOptions): string
Parameters:
Name | Type |
---|---|
| string |
| undefined | object |
| qs.IStringifyOptions |
Returns: string
Const
urlDecode
Const
urlDecode▸ urlDecode<T>(value
: string, options?
: qs.IParseOptions): T
Type parameters:
▪ T
Parameters:
Name | Type |
---|---|
| string |
| qs.IParseOptions |
Returns: T
Const
urlDestruct
Const
urlDestruct▸ urlDestruct(url
: string, options?
: qs.IParseOptions): object
Parameters:
Name | Type |
---|---|
| string |
| qs.IParseOptions |
Returns: object
query: any
url: string
Const
urlEncode
Const
urlEncode▸ urlEncode(value
: any, options?
: qs.IStringifyOptions): string
Parameters:
Name | Type |
---|---|
| any |
| qs.IStringifyOptions |
Returns: string
Const
useInterceptor
Const
useInterceptor▸ useInterceptor(normalizedOptions
: NormalizedHttpOptions): (Anonymous function)
Parameters:
Name | Type |
---|---|
| NormalizedHttpOptions |
Returns: (Anonymous function)
Const
xhrRequestHandler
Const
xhrRequestHandler▸ xhrRequestHandler(_?
: XhrRequestHandlerOptions): HttpRequestHandler
Parameters:
Name | Type |
---|---|
| XhrRequestHandlerOptions |
Returns: HttpRequestHandler
Object literals
Const
ContentTypeRegex
Const
ContentTypeRegex▪ ContentTypeRegex: object
JSON
• JSON: RegExp‹› = /^application/(json|.++json)$/
MULTIPART
• MULTIPART: RegExp‹› = /^multipart//
TEXT
• TEXT: RegExp‹› = /^text//
URL_ENCODED
• URL_ENCODED: RegExp‹› = /^application/x-www-form-urlencoded$/
Const
HttpClientHelper
Const
HttpClientHelper▪ HttpClientHelper: object
defaultHeaders
• defaultHeaders: defaultHeaders
getHostname
• getHostname: getHostname
toUrlEncoded
• toUrlEncoded: toUrlEncoded
Const
HttpStatusText
Const
HttpStatusText▪ HttpStatusText: object
__computed
• __computed: string = "Network Authentication Required"
Const
Interceptors
Const
Interceptors▪ Interceptors: object
createErrorInterceptor
• createErrorInterceptor: createErrorInterceptor
createLoggingInterceptor
• createLoggingInterceptor: createLoggingInterceptor
createRedirectionInterceptor
• createRedirectionInterceptor: createRedirectionInterceptor
Last updated