IHttpClient
Interface | Source Code
Properties
Section titled “Properties”onError: Event
Section titled “onError: Event”Triggered on a general network error. Does not occur on non-200 series responses.
onReceiveResponse: Event<ReceiveResponseHandler>
Section titled “onReceiveResponse: Event<ReceiveResponseHandler>”Triggered when a response is received.
onSendRequest: Event<SendRequestHandler>
Section titled “onSendRequest: Event<SendRequestHandler>”Triggered just before a request is sent.
defaultRequestOptions?: Partial
Section titled “defaultRequestOptions?: Partial”Default options to include in all requests this client makes. Each option should be overrideable if the same option is defined in the provided options when making a request.
protocol?: string
Section titled “protocol?: string”A default protocol and domain to use for the instance. It will be prepended to all request URIs if given during construction.
Example
Section titled “Example”'https://my.site.com/''http://my.site.com'Methods
Section titled “Methods”delete(uri: string, requestData?: BasicHttpRequestData<RawResponseBodyType, ParsedBodyType, HttpRequestOptionsType>): Promise<Partial<BasicHttpResponseData>>
Section titled “delete(uri: string, requestData?: BasicHttpRequestData<RawResponseBodyType, ParsedBodyType, HttpRequestOptionsType>): Promise<Partial<BasicHttpResponseData>>”Convenience function for sending a DELETE request.
Returns
Section titled “Returns”A promise that resolves to response data. The properties of the returned object may be undefined if a fetch
error occurred during processing. To globally address fetch errors made by this client, use the onFetchError event.
To address errors for individual requests, use the allowThrow option on the request and handle it via try/catch.
get(uri: string, requestData?: Omit<BasicHttpRequestData<RawResponseBodyType, ParsedBodyType, HttpRequestOptionsType>, “body”>): Promise<Partial<BasicHttpResponseData>>
Section titled “get(uri: string, requestData?: Omit<BasicHttpRequestData<RawResponseBodyType, ParsedBodyType, HttpRequestOptionsType>, “body”>): Promise<Partial<BasicHttpResponseData>>”Convenience function for sending a GET request.
Returns
Section titled “Returns”A promise that resolves to response data. The properties of the returned object may be undefined if a fetch
error occurred during processing. To globally address fetch errors made by this client, use the onFetchError event.
To address errors for individual requests, use the allowThrow option on the request and handle it via try/catch.
makeRequest(method: string, uri: string, requestData?: BasicHttpRequestData<RawResponseBodyType, ParsedBodyType, HttpRequestOptionsType>): Promise<Partial<BasicHttpResponseData>>
Section titled “makeRequest(method: string, uri: string, requestData?: BasicHttpRequestData<RawResponseBodyType, ParsedBodyType, HttpRequestOptionsType>): Promise<Partial<BasicHttpResponseData>>”Perform a request with the specified method. Useful if the convenience functions don’t provide the HTTP verb you need.
Returns
Section titled “Returns”A promise that resolves to response data. The properties of the returned object may be undefined if a fetch
error occurred during processing. To globally address fetch errors made by this client, use the onFetchError event.
To address errors for individual requests, use the allowThrow option on the request and handle it via try/catch.
patch(uri: string, requestData?: BasicHttpRequestData<RawResponseBodyType, ParsedBodyType, HttpRequestOptionsType>): Promise<Partial<BasicHttpResponseData>>
Section titled “patch(uri: string, requestData?: BasicHttpRequestData<RawResponseBodyType, ParsedBodyType, HttpRequestOptionsType>): Promise<Partial<BasicHttpResponseData>>”Convenience function for sending a PATCH request.
Returns
Section titled “Returns”A promise that resolves to response data. The properties of the returned object may be undefined if a fetch
error occurred during processing. To globally address fetch errors made by this client, use the onFetchError event.
To address errors for individual requests, use the allowThrow option on the request and handle it via try/catch.
post(uri: string, requestData?: BasicHttpRequestData<RawResponseBodyType, ParsedBodyType, HttpRequestOptionsType>): Promise<Partial<BasicHttpResponseData>>
Section titled “post(uri: string, requestData?: BasicHttpRequestData<RawResponseBodyType, ParsedBodyType, HttpRequestOptionsType>): Promise<Partial<BasicHttpResponseData>>”Convenience function for sending a POST request.
Returns
Section titled “Returns”A promise that resolves to response data. The properties of the returned object may be undefined if a fetch
error occurred during processing. To globally address fetch errors made by this client, use the onFetchError event.
To address errors for individual requests, use the allowThrow option on the request and handle it via try/catch.
put(uri: string, requestData?: BasicHttpRequestData<RawResponseBodyType, ParsedBodyType, HttpRequestOptionsType>): Promise<Partial<BasicHttpResponseData>>
Section titled “put(uri: string, requestData?: BasicHttpRequestData<RawResponseBodyType, ParsedBodyType, HttpRequestOptionsType>): Promise<Partial<BasicHttpResponseData>>”Convenience function for sending a PUT request.
Returns
Section titled “Returns”A promise that resolves to response data. The properties of the returned object may be undefined if a fetch
error occurred during processing. To globally address fetch errors made by this client, use the onFetchError event.
To address errors for individual requests, use the allowThrow option on the request and handle it via try/catch.