用户:
没尾巴的鲸鱼_查看:1 回复:11 评论:1 创建时间:2023-09-23T16:22:25
最近扒岛三API声明文件,发现了访问网站的接口
fetch: (url: string, options?: GameHttpFetchRequestOptions) => Promise<GameHttpFetchResponse>; 发现:
http.fetch 函数需要参数url:string,options参数则是一个对象:
{
timeout?: number; //超时
method?: 'OPTIONS' | 'GET' | 'HEAD' | 'PUT' | 'POST' | 'DELETE' | 'PATCH'; //请求方法
headers?: GameHttpFetchHeaders; //请求头
body?: string | ArrayBuffer; //请求体
}; 其中,GameHttpFetchHeaders(请求头)定义为:
[name: string]: string | string[]; 随后,fetch方喵返回对象GameHttpFetchResponse:
declare class GameHttpFetchResponse {
status: number;
statusText: string;
headers: GameHttpFetchHeaders;
json: () => Promise<any>;
text: () => Promise<string>;
arrayBuffer: () => Promise<ArrayBuffer>;
close: () => Promise<void>;
constructor(status: number, statusText: string, headers: GameHttpFetchHeaders, json: () => Promise<any>, text: () => Promise<string>, arrayBuffer: () => Promise<ArrayBuffer>, close: () => Promise<void>);
get ok(): boolean;
}
其中,status返回状态码;
json()返回对象数据;
text()返回文字数据;
close()方法关闭连接;
成员ok为布尔值,返回是否连接成功。
以上就是http隐藏API的用法,各位自取!将会持续更新API透露!