@gct-paas/api 0.1.6-dev.3 → 0.1.6-dev.4
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.
|
@@ -22,14 +22,4 @@ export function installHttpUtil() {
|
|
|
22
22
|
config.headers["App-Tag"] = "__platform__";
|
|
23
23
|
return config;
|
|
24
24
|
}, errorHandler);
|
|
25
|
-
HttpUtil._instance.interceptors.response.use((response) => {
|
|
26
|
-
if (response.data.code === 200) {
|
|
27
|
-
return response.data.data;
|
|
28
|
-
}
|
|
29
|
-
const errorMessageMode = response.config?.errorMessageMode;
|
|
30
|
-
if (errorMessageMode !== "none") {
|
|
31
|
-
console.log(response.data.message);
|
|
32
|
-
}
|
|
33
|
-
return Promise.reject(response.data);
|
|
34
|
-
}, errorHandler);
|
|
35
25
|
}
|
|
@@ -15,7 +15,7 @@ export const NativeHTTP = {
|
|
|
15
15
|
const allUrl = (baseURL + url).replace(/([^:])\/\//g, "$1/") + pathParam;
|
|
16
16
|
console.info(allUrl + ">>HTTP", querydata);
|
|
17
17
|
const startTime = performance.now();
|
|
18
|
-
return new Promise((resolve
|
|
18
|
+
return new Promise((resolve) => {
|
|
19
19
|
dsBridge.call(
|
|
20
20
|
"HTTP." + method,
|
|
21
21
|
{
|
|
@@ -30,15 +30,21 @@ export const NativeHTTP = {
|
|
|
30
30
|
`${allUrl} >> HTTP.response - \u8017\u65F6\uFF1A${performance.now() - startTime}`,
|
|
31
31
|
nativeData
|
|
32
32
|
);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
let data2 = {};
|
|
34
|
+
if (nativeData.data) {
|
|
35
|
+
try {
|
|
36
|
+
data2 = JSON.parse(nativeData.data);
|
|
37
|
+
} catch (e) {
|
|
38
|
+
console.warn("NativeHTTP: \u65E0\u6CD5\u89E3\u6790\u54CD\u5E94\u6570\u636E\uFF0C\u8FD4\u56DE\u539F\u59CB\u6570\u636E", e);
|
|
39
|
+
data2 = nativeData.data;
|
|
40
|
+
}
|
|
41
41
|
}
|
|
42
|
+
resolve({
|
|
43
|
+
status: nativeData.http_code,
|
|
44
|
+
statusText: nativeData.message,
|
|
45
|
+
data: data2,
|
|
46
|
+
config: querydata
|
|
47
|
+
});
|
|
42
48
|
}
|
|
43
49
|
);
|
|
44
50
|
});
|