跳转到主要内容
通用 HTTP 客户端,适用于 Node.js 和浏览器环境

构造器

构造函数

new HttpClient(): HttpClient

返回值

HttpClient

定义于

http-client.ts:41

方法

createHeaders

createHeaders(init?): Headers 创建新的 Headers 实例

参数

名称类型
init?Record<string, string>Headers

返回值

Headers

定义于

http-client.ts:91

request

request(url, options?): Promise<HttpResponse> 发起 HTTP 请求

参数

名称类型
urlstring
optionsHttpClientRequestOptions

返回值

Promise<HttpResponse>

定义于

http-client.ts:98

get

get(url, headers?): Promise<HttpResponse> 发起 GET 请求

参数

名称类型
urlstring
headers?Record<string, string>

返回值

Promise<HttpResponse>

定义于

http-client.ts:135

post

post(url, body?, headers?): Promise<HttpResponse> 发起 POST 请求

参数

名称类型
urlstring
body?string
headers?Record<string, string>

返回值

Promise<HttpResponse>

定义于

http-client.ts:148

put

put(url, body?, headers?): Promise<HttpResponse> 发起一个 PUT 请求

参数

参数名类型
urlstring
body?string
headers?Record<string, string>

返回值

Promise<HttpResponse>

定义于

http-client.ts:163

delete

delete(url, headers?): Promise<HttpResponse> 发送 DELETE 请求

参数

名称类型
urlstring
headers?Record<string, string>

返回值

Promise<HttpResponse>

定义位置

http-client.ts:178

patch

patch(url, body?, headers?): Promise<HttpResponse> 发起 PATCH 请求

参数

参数名类型
urlstring
body?string
headers?Record<string, string>

返回

Promise<HttpResponse>

定义于

http-client.ts:191