Skip to main content

bn.request

request(options): RequestTask

Initiates an HTTPS request.

example

bn.request({
url: 'https://nezha-mock.fe.qa1fdg.net/order',
responseType: 'text',
dataType: 'json',
success: (res) => {
console.log(res)
}
})

Parameters

NameTypeDescription
optionsRequestOption<string | ArrayBuffer | IUnknownObject>request options

Returns

RequestTask

request task

Interface: RequestOption<T>

NameTypeDescription
urlstringrequest url
data?string | ArrayBuffer | IUnknownObjectrequest params
header?Headersset request header, can't set Referer. default value of content-type is application/json
timeout?numbertimeout of request, unit is millisecond
method?"OPTIONS" | "HEAD" | "GET" | "POST" | "PUT" | "DELETE"HTTP request method
dataType?stringReturned data format. 'json' - the returned data is JSON. After returning, JSON.parse will be performed on the returned data.
responseType?"text" | "arraybuffer"Response data type. 'text' - The response data is text; 'arraybuffer' - The response data is ArrayBuffer
usePrefetchCache?booleanusing prefetched data**remark** support from jssdk > 4.0.0
fail?RequestFailCallbackCallback function for failed interface call
success?RequestSuccessCallback<T>Callback function for successful interface call
complete?RequestCompleteCallbackhe callback function for the end of the interface call

IUnknownObject

Ƭ IUnknownObject: Object


Interface: RequestTask

NameTypeDescription
abort(): voidInterrupt request task
offHeadersReceived(callback?): voidCancel listening for HTTP Response Header event
onHeadersReceived(callback): voidListen to the HTTP Response Header event. Will be earlier than the requested completion event

abort

abort(): void

Interrupt request task

Returns

void


offHeadersReceived

offHeadersReceived(callback?): void

Cancel listening for HTTP Response Header event

Parameters

NameType
callback?OffHeadersReceivedCallback

Returns

void


onHeadersReceived

onHeadersReceived(callback): void

Listen to the HTTP Response Header event. Will be earlier than the requested completion event

Parameters

NameType
callbackOnHeadersReceivedCallback

Returns

void

OffHeadersReceivedCallback

Ƭ OffHeadersReceivedCallback: (result: OnHeadersReceivedCallbackResult) => void

Type declaration

▸ (result): void

Parameters

NameType
resultOnHeadersReceivedCallbackResult

Returns

void


Interface: OnHeadersReceivedCallbackResult

NameTypeDescription
headerHeadersHTTP Response Header

OnHeadersReceivedCallback

Ƭ OnHeadersReceivedCallback: (result: OnHeadersReceivedCallbackResult) => void

Type declaration

▸ (result): void

Parameters

NameType
resultOnHeadersReceivedCallbackResult

Returns

void