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
datastring | ArrayBuffer | IUnknownObjectrequest params
headerHeadersset request header, can't set Referer. default value of content-type is application/json
timeoutnumbertimeout of request, unit is millisecond
method"OPTIONS" | "HEAD" | "GET" | "POST" | "PUT" | "DELETE"HTTP request method
dataTypestringReturned 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
usePrefetchCachebooleanusing prefetched dataremark support from jssdk > 4.0.0
failRequestFailCallbackCallback function for failed interface call
successRequestSuccessCallback<T>Callback function for successful interface call
completeRequestCompleteCallbackhe 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