aisbreaker-api-js - v0.1.15 / utils/KyHttpClientUtils
Module: utils/KyHttpClientUtils
Table of contents
Functions
- kyHooksBeforeErrorToReduceLogging
- kyHooksToReduceLogging
- kyOnDownloadProgress4onMessage
- tryToCreateAIsErrorFromKyResponse
Functions
kyHooksBeforeErrorToReduceLogging
▸ kyHooksBeforeErrorToReduceLogging(debug?
): (error
: HTTPError
) => Promise
<HTTPError
>[]
Parameters
Name | Type |
---|---|
debug? | boolean |
Returns
(error
: HTTPError
) => Promise
<HTTPError
>[]
Defined in
aisbreaker-js/packages/aisbreaker-api-js/src/utils/KyHttpClientUtils.ts:100
kyHooksToReduceLogging
▸ kyHooksToReduceLogging(debug?
): Object
Default hook for ky.*()
Reduce logging spam by deleting some ky error details in the case of an HTTPError
Parameters
Name | Type |
---|---|
debug? | boolean |
Returns
Object
Name | Type |
---|---|
beforeError | (error : HTTPError ) => Promise <HTTPError >[] |
Defined in
aisbreaker-js/packages/aisbreaker-api-js/src/utils/KyHttpClientUtils.ts:94
kyOnDownloadProgress4onMessage
▸ kyOnDownloadProgress4onMessage(onMessage
): (progress
: DownloadProgress
, chunk
: Uint8Array
) => void
Mapping onMessage() event handler to onDownloadProgress(). Useful for ky.post() / onDownloadProgress
Parameters
Name | Type |
---|---|
onMessage | (message : EventSourceMessage ) => void |
Returns
fn
▸ (progress
, chunk
): void
Parameters
Name | Type |
---|---|
progress | DownloadProgress |
chunk | Uint8Array |
Returns
void
Defined in
aisbreaker-js/packages/aisbreaker-api-js/src/utils/KyHttpClientUtils.ts:60
tryToCreateAIsErrorFromKyResponse
▸ tryToCreateAIsErrorFromKyResponse(response
): Promise
<AIsError
| undefined
>
Throws an AIsError if the response contains an error, otherwise it just returns
Parameters
Name | Type | Description |
---|---|---|
response | any | ky response, potenially with an JSON-encoded AIsError |
Returns
Promise
<AIsError
| undefined
>
the AIsError if the response contains an error, otherwise undefined
Defined in
aisbreaker-js/packages/aisbreaker-api-js/src/utils/KyHttpClientUtils.ts:145