etherreq 1.0.13 → 1.0.14
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 +1 -1
- package/src/etherreq.js +4 -10
package/package.json
CHANGED
package/src/etherreq.js
CHANGED
|
@@ -28,16 +28,10 @@ export const create = (defaultConfig = {}) => {
|
|
|
28
28
|
|
|
29
29
|
const res = await fetch(url, options);
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (contentType && contentType.includes('application/json')) {
|
|
36
|
-
data = await res.json(); // 只有 JSON 内容才尝试解析
|
|
37
|
-
} else {
|
|
38
|
-
data = await res.text(); // 保存原始文本避免报错
|
|
39
|
-
throw new Error('非 JSON 响应,可能已跳转至登录页');
|
|
40
|
-
}
|
|
31
|
+
const data = await res.json();
|
|
32
|
+
console.log(data);
|
|
33
|
+
|
|
34
|
+
|
|
41
35
|
|
|
42
36
|
if (!res.ok) {
|
|
43
37
|
const error = new Error(`HTTP 错误: ${res.status} - ${res.statusText}`);
|