Class: APIPromise<T>
A promise for the parsed result that also exposes the HTTP response. Await it for the data, or call .withResponse() for the Response and request ID too. Non-2xx responses reject with an APIError.
继承自
Promise<T>
类型参数
T
T
构造函数
构造函数
new APIPromise<T>(raw, parse): APIPromise<T>;参数
raw
Promise<RawResponse>
parse
(raw) => T | Promise<T>
返回
APIPromise<T>
重写
Promise<T>.constructor访问器
[species]
Getter 签名
get static species: PromiseConstructor;返回
PromiseConstructor
重写
Promise.[species]方法
asResponse()
asResponse(): Promise<Response>;返回原始 Response,不解析响应体。SDK 已在超时时间内把响应体读入内存, 这里返回的是它的一个新副本,可自由读取。
Resolve to the raw Response without parsing. The SDK has already buffered the body within the timeout; this is a fresh copy you may read freely.
返回
Promise<Response>
catch()
catch<TResult>(onrejected?): Promise<T | TResult>;Attaches a callback for only the rejection of the Promise.
类型参数
TResult
TResult = never
参数
onrejected?
((reason) => TResult | PromiseLike<TResult>) | null
The callback to execute when the Promise is rejected.
返回
Promise<T | TResult>
A Promise for the completion of the callback.
重写
Promise.catchfinally()
finally(onfinally?): Promise<T>;Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The resolved value cannot be modified from the callback.
参数
onfinally?
(() => void) | null
The callback to execute when the Promise is settled (fulfilled or rejected).
返回
Promise<T>
A Promise for the completion of the callback.
重写
Promise.finallymap()
map<U>(fn): APIPromise<U>;变换解析结果,共享同一个 HTTP 响应与同一次解析。
Transform the parsed result, sharing the HTTP response and a single parse.
类型参数
U
U
参数
fn
(data) => U | Promise<U>
返回
APIPromise<U>
then()
then<TResult1, TResult2>(onfulfilled?, onrejected?): Promise<TResult1 | TResult2>;Attaches callbacks for the resolution and/or rejection of the Promise.
类型参数
TResult1
TResult1 = T
TResult2
TResult2 = never
参数
onfulfilled?
((value) => TResult1 | PromiseLike<TResult1>) | null
The callback to execute when the Promise is resolved.
onrejected?
((reason) => TResult2 | PromiseLike<TResult2>) | null
The callback to execute when the Promise is rejected.
返回
Promise<TResult1 | TResult2>
A Promise for the completion of which ever callback is executed.
重写
Promise.thenwithResponse()
withResponse(): Promise<WithResponse<T>>;同时返回解析后的数据、HTTP 响应与 x-request-id。
Resolve to the parsed data, the HTTP response, and the x-request-id.
返回
Promise<WithResponse<T>>

