共用方式為


WebResource class

建立新的 WebResource 物件。

這個類別提供 REST 呼叫的抽象概念,其方式是程式庫/實作無關,並包裝必要的屬性來起始要求。

建構函式

WebResource(string, HttpMethods, any, {[key: string]: any}, {[key: string]: any} | HttpHeadersLike, boolean, boolean, AbortSignalLike, number, (progress: TransferProgressEvent) => void, (progress: TransferProgressEvent) => void, ProxySettings, boolean, AgentSettings, number)

屬性

abortSignal
agentSettings
body
formData
headers
keepAlive
method
onDownloadProgress

下載進度時引發的回呼。

onUploadProgress

上傳進度時引發的回呼。

operationResponseGetter

函式,針對指定的 OperationSpec 和 HttpOperationResponse 組合傳回適當的 OperationResponse。 如果未定義,則會使用簡單的狀態碼查閱。

operationSpec
proxySettings
query
redirectLimit
shouldDeserialize

是否應該還原序列化 HttpOperationResponse。 如果未定義,則應該還原序列化 HttpOperationResponse。

streamResponseBody

是否應該將 HttpOperationResponse 的主體視為資料流程。

timeout
url
withCredentials

方法

clone()

複製此 WebResource HTTP 要求物件。

prepare(RequestPrepareOptions)

準備要求。

validateRequestProperties()

驗證已定義必要屬性,例如方法、URL、標頭[「Content-Type」]、headers[「accept-language」] 。 如果未定義上述其中一個屬性,則會擲回錯誤。

建構函式詳細資料

WebResource(string, HttpMethods, any, {[key: string]: any}, {[key: string]: any} | HttpHeadersLike, boolean, boolean, AbortSignalLike, number, (progress: TransferProgressEvent) => void, (progress: TransferProgressEvent) => void, ProxySettings, boolean, AgentSettings, number)

new WebResource(url?: string, method?: HttpMethods, body?: any, query?: {[key: string]: any}, headers?: {[key: string]: any} | HttpHeadersLike, streamResponseBody?: boolean, withCredentials?: boolean, abortSignal?: AbortSignalLike, timeout?: number, onUploadProgress?: (progress: TransferProgressEvent) => void, onDownloadProgress?: (progress: TransferProgressEvent) => void, proxySettings?: ProxySettings, keepAlive?: boolean, agentSettings?: AgentSettings, redirectLimit?: number)

參數

url

string

method
HttpMethods
body

any

query

{[key: string]: any}

headers

{[key: string]: any} | HttpHeadersLike

streamResponseBody

boolean

withCredentials

boolean

abortSignal
AbortSignalLike
timeout

number

onUploadProgress

(progress: TransferProgressEvent) => void

onDownloadProgress

(progress: TransferProgressEvent) => void

proxySettings
ProxySettings
keepAlive

boolean

agentSettings
AgentSettings
redirectLimit

number

屬性詳細資料

abortSignal

abortSignal?: AbortSignalLike

屬性值

agentSettings

agentSettings?: AgentSettings

屬性值

body

body?: any

屬性值

any

formData

formData?: any

屬性值

any

headers

headers: HttpHeadersLike

屬性值

keepAlive

keepAlive?: boolean

屬性值

boolean

method

method: HttpMethods

屬性值

onDownloadProgress

下載進度時引發的回呼。

onDownloadProgress?: (progress: TransferProgressEvent) => void

屬性值

(progress: TransferProgressEvent) => void

onUploadProgress

上傳進度時引發的回呼。

onUploadProgress?: (progress: TransferProgressEvent) => void

屬性值

(progress: TransferProgressEvent) => void

operationResponseGetter

函式,針對指定的 OperationSpec 和 HttpOperationResponse 組合傳回適當的 OperationResponse。 如果未定義,則會使用簡單的狀態碼查閱。

operationResponseGetter?: (operationSpec: OperationSpec, response: HttpOperationResponse) => undefined | OperationResponse

屬性值

(operationSpec: OperationSpec, response: HttpOperationResponse) => undefined | OperationResponse

operationSpec

operationSpec?: OperationSpec

屬性值

proxySettings

proxySettings?: ProxySettings

屬性值

query

query?: {[key: string]: any}

屬性值

{[key: string]: any}

redirectLimit

redirectLimit?: number

屬性值

number

shouldDeserialize

是否應該還原序列化 HttpOperationResponse。 如果未定義,則應該還原序列化 HttpOperationResponse。

shouldDeserialize?: boolean | (response: HttpOperationResponse) => boolean

屬性值

boolean | (response: HttpOperationResponse) => boolean

streamResponseBody

是否應該將 HttpOperationResponse 的主體視為資料流程。

streamResponseBody?: boolean

屬性值

boolean

timeout

timeout: number

屬性值

number

url

url: string

屬性值

string

withCredentials

withCredentials: boolean

屬性值

boolean

方法詳細資料

clone()

複製此 WebResource HTTP 要求物件。

function clone(): WebResource

傳回

這個 WebResource HTTP 要求物件的複製品。

prepare(RequestPrepareOptions)

準備要求。

function prepare(options: RequestPrepareOptions): WebResource

參數

options
RequestPrepareOptions

提供準備要求的選項。

傳回

傳回需要提供給要求管線的已備妥 WebResource (HTTP 要求) 物件。

validateRequestProperties()

驗證已定義必要屬性,例如方法、URL、標頭[「Content-Type」]、headers[「accept-language」] 。 如果未定義上述其中一個屬性,則會擲回錯誤。

function validateRequestProperties()