@bettergi/types 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +3 -0
- package/modules/http.d.ts +41 -0
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
type HttpReponse = {
|
|
2
|
+
/** 状态码 */
|
|
3
|
+
status_code: number;
|
|
4
|
+
|
|
5
|
+
/** 响应头 */
|
|
6
|
+
headers: Record<string, string>;
|
|
7
|
+
|
|
8
|
+
/** 响应体 */
|
|
9
|
+
body: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
declare global {
|
|
13
|
+
/** @since 0.52.0 */
|
|
14
|
+
namespace http {
|
|
15
|
+
/**
|
|
16
|
+
* 发送HTTP请求
|
|
17
|
+
* @param method 请求方法
|
|
18
|
+
* @param url 请求URL
|
|
19
|
+
* @param body 请求体(可选)
|
|
20
|
+
* @param headersJson 请求头(可选)
|
|
21
|
+
* @since 0.52.0
|
|
22
|
+
*/
|
|
23
|
+
function request(
|
|
24
|
+
method:
|
|
25
|
+
| "GET"
|
|
26
|
+
| "PUT"
|
|
27
|
+
| "POST"
|
|
28
|
+
| "DELETE"
|
|
29
|
+
| "HEAD"
|
|
30
|
+
| "OPTIONS"
|
|
31
|
+
| "TRACE"
|
|
32
|
+
| "PATCH"
|
|
33
|
+
| "CONNECT",
|
|
34
|
+
url: string,
|
|
35
|
+
body?: string,
|
|
36
|
+
headersJson?: string
|
|
37
|
+
): Promise<HttpReponse>;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export {};
|