MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / request

Method request

packages/filesystem/baidu/baidu.ts:59–83  ·  view source on GitHub ↗
(url: string, config?: RequestInit)

Source from the content-addressed store, hash-verified

57 }
58
59 async request(url: string, config?: RequestInit) {
60 config = config || {};
61 const headers = <Headers>config.headers || new Headers();
62 config.headers = headers;
63 // 对百度网盘请求显式禁用 cookie,避免依赖全局 DNR 规则造成并发竞态
64 config.credentials = "omit";
65 return fetch(url, config)
66 .then((data) => data.json())
67 .then(async (data) => {
68 if (data.errno === 111 || data.errno === -6) {
69 const token = await AuthVerify("baidu", true);
70 this.accessToken = token;
71 url = url.replace(/access_token=[^&]+/, `access_token=${token}`);
72 return fetch(url, config)
73 .then((data2) => data2.json())
74 .then((data2) => {
75 if (data2.errno === 111 || data2.errno === -6) {
76 throw new Error(JSON.stringify(data2));
77 }
78 return data2;
79 });
80 }
81 return data;
82 });
83 }
84
85 delete(path: string): Promise<void> {
86 const filelist = [joinPath(this.path, path)];

Callers 6

createDirMethod · 0.95
deleteMethod · 0.95
listMethod · 0.95
baidu.test.tsFile · 0.45
readMethod · 0.45
writeMethod · 0.45

Calls 2

AuthVerifyFunction · 0.90
jsonMethod · 0.45

Tested by

no test coverage detected