etherreq 1.1.9 → 1.1.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/request.js +3 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "etherreq",
3
- "version": "1.1.9",
3
+ "version": "1.1.11",
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/request.js CHANGED
@@ -21,14 +21,7 @@ instance.interceptors.request.use((config) => {
21
21
  const cacheKey = getCacheKey(config.url, config);
22
22
  const cached = requestCache.get(cacheKey);
23
23
  if (cached) {
24
- const fakeResponse = {
25
- data: cached,
26
- status: 200,
27
- statusText: 'OK',
28
- config,
29
- isFromCache: true, // ✅ 添加标志位
30
- };
31
- return Promise.resolve(fakeResponse); // ✅ 返回响应对象,中断请求链
24
+ return Promise.resolve(cached); // ✅ 返回响应对象,中断请求链
32
25
  }
33
26
  }
34
27
 
@@ -42,11 +35,8 @@ instance.interceptors.request.use((config) => {
42
35
  instance.interceptors.response.use(
43
36
  (response) => {
44
37
  // 如果是缓存命中,直接返回 cached 数据
45
- console.log(response);
46
- console.log(response.isFromCache);
47
- if (response && response.isFromCache) {
48
- console.log('使用缓存数据');
49
- console.log('返回数据', response.data);
38
+
39
+ if (response ) {
50
40
  return response.data; // ✅ 返回 cached 数据
51
41
  }
52
42