etherreq 1.0.39 → 1.1.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "etherreq",
3
- "version": "1.0.39",
3
+ "version": "1.1.1",
4
4
  "description": "A lightweight custom HTTP request library.",
5
5
  "main": "src/index.js",
6
6
  "types": "src/types/etherreq.d.ts",
package/src/etherreq.js CHANGED
@@ -26,7 +26,6 @@ const dispatchRequest = async (config) => {
26
26
  let response;
27
27
  const { url, method = 'GET', headers = {}, body } = config;
28
28
  let text = '';
29
-
30
29
  try {
31
30
  const options = {
32
31
  method,
@@ -35,9 +34,7 @@ const dispatchRequest = async (config) => {
35
34
  };
36
35
 
37
36
  const res = await fetch(url, options);
38
-
39
37
  text = await res.text();
40
-
41
38
  if (!res.ok) {
42
39
  throw new Error(`HTTP 错误: ${res.status} - ${res.statusText}`);
43
40
  }
package/src/request.js CHANGED
@@ -20,18 +20,15 @@ instance.interceptors.request.use((config) => {
20
20
  if (config.method === 'GET' && !config.disableCache) {
21
21
  const cacheKey = getCacheKey(config.url, config);
22
22
  const cached = requestCache.get(cacheKey);
23
- console.log("缓存数据:", cached);
24
-
25
23
  if (cached) {
26
- console.log("缓存命中");
27
- const fakeResponse = {
28
- data: cached,
29
- status: 200,
30
- statusText: 'OK',
31
- config,
32
- isFromCache: true, // ✅ 添加标志位
33
- };
34
- return Promise.resolve(fakeResponse); // ✅ 返回响应对象,中断请求链
24
+ // const fakeResponse = {
25
+ // data: cached,
26
+ // status: 200,
27
+ // statusText: 'OK',
28
+ // config,
29
+ // isFromCache: true, // ✅ 添加标志位
30
+ // };
31
+ return Promise.resolve(cached); // ✅ 返回响应对象,中断请求链
35
32
  }
36
33
  }
37
34