@ichaingo/request 1.4.90 → 1.4.92
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/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -9
- package/dist/interceptors/response.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,UAAU,EAAE,MAAM,OAAO,CAAC;AAQ/C,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,IAAI,EAAE,CAAC,CAAC;CACT;AAED,MAAM,WAAW,QAAS,SAAQ,UAAU;IAC1C,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAGD,QAAA,MAAM,aAAa,+
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,UAAU,EAAE,MAAM,OAAO,CAAC;AAQ/C,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,IAAI,EAAE,CAAC,CAAC;CACT;AAED,MAAM,WAAW,QAAS,SAAQ,UAAU;IAC1C,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAGD,QAAA,MAAM,aAAa,+BAYjB,CAAC;AASH,eAAe,aAAa,CAAC;AAE7B,YAAY,EACV,gBAAgB,EAChB,UAAU,EACV,MAAM,EACN,SAAS,EACT,QAAQ,EACR,YAAY,GACb,MAAM,SAAS,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -105,19 +105,17 @@ function errorInterceptor(error) {
|
|
|
105
105
|
return Promise.reject(err);
|
|
106
106
|
}
|
|
107
107
|
function ResponseInterceptor(response) {
|
|
108
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j
|
|
108
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
109
109
|
const config = response.config;
|
|
110
110
|
if (config.returnFullResponse) {
|
|
111
111
|
return response;
|
|
112
112
|
}
|
|
113
113
|
if (response.status === 401) {
|
|
114
114
|
TokenManager.removeAllToken();
|
|
115
|
-
const locale = ((_a = config == null ? void 0 : config.headers) == null ? void 0 : _a["Accept-Language"]) || "en";
|
|
116
|
-
window.location.href = `${process.env.NEXT_PUBLIC_BASE_URL}/${locale}/login`;
|
|
117
115
|
return response;
|
|
118
116
|
}
|
|
119
117
|
if (response.status === 200) {
|
|
120
|
-
if ((
|
|
118
|
+
if ((_a = response.headers["content-type"]) == null ? void 0 : _a.includes("text/event-stream")) {
|
|
121
119
|
return response;
|
|
122
120
|
}
|
|
123
121
|
const data = response.data;
|
|
@@ -130,11 +128,11 @@ function ResponseInterceptor(response) {
|
|
|
130
128
|
response.request,
|
|
131
129
|
response
|
|
132
130
|
);
|
|
133
|
-
const summary = `BIZ ${businessStatus.code} | ${(
|
|
131
|
+
const summary = `BIZ ${businessStatus.code} | ${(_c = (_b = response.config) == null ? void 0 : _b.method) == null ? void 0 : _c.toUpperCase()} | ${((_d = response.config) == null ? void 0 : _d.baseURL) || ""}${((_e = response.config) == null ? void 0 : _e.url) || ""} | server: ${businessStatus == null ? void 0 : businessStatus.msg}`;
|
|
134
132
|
const details = {
|
|
135
|
-
method: (
|
|
136
|
-
url: ((
|
|
137
|
-
params: (
|
|
133
|
+
method: (_g = (_f = response.config) == null ? void 0 : _f.method) == null ? void 0 : _g.toUpperCase(),
|
|
134
|
+
url: ((_h = response.config) == null ? void 0 : _h.baseURL) ? `${response.config.baseURL}${response.config.url || ""}` : response.config.url,
|
|
135
|
+
params: (_i = response.config) == null ? void 0 : _i.params,
|
|
138
136
|
data: (() => {
|
|
139
137
|
var _a2;
|
|
140
138
|
let d = (_a2 = response.config) == null ? void 0 : _a2.data;
|
|
@@ -148,7 +146,7 @@ function ResponseInterceptor(response) {
|
|
|
148
146
|
})(),
|
|
149
147
|
status: response.status,
|
|
150
148
|
statusText: response.statusText,
|
|
151
|
-
requestId: ((
|
|
149
|
+
requestId: ((_j = response.headers) == null ? void 0 : _j["x-request-id"]) || (businessStatus == null ? void 0 : businessStatus.requestId),
|
|
152
150
|
responseData: data
|
|
153
151
|
};
|
|
154
152
|
if (process.env.NODE_ENV !== "development") {
|
|
@@ -212,6 +210,9 @@ const axiosInstance = axios.create({
|
|
|
212
210
|
timeout: 1e4,
|
|
213
211
|
withCredentials: true,
|
|
214
212
|
// Always include credentials by default
|
|
213
|
+
// Treat HTTP 401 as a non-error response so it goes through responseInterceptor.
|
|
214
|
+
// This allows callers to handle 401 via the returned AxiosResponse instead of catch().
|
|
215
|
+
validateStatus: (status) => status >= 200 && status < 300 || status === 401,
|
|
215
216
|
paramsSerializer: function(params) {
|
|
216
217
|
return qs.stringify(params, { arrayFormat: "brackets" });
|
|
217
218
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/interceptors/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,aAAa,EAAE,MAAM,OAAO,CAAC;AAKlD,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,QAAQ,EAAE,aAAa,GAAG,GAAG,
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/interceptors/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,aAAa,EAAE,MAAM,OAAO,CAAC;AAKlD,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,QAAQ,EAAE,aAAa,GAAG,GAAG,CAoDxE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ichaingo/request",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.92",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"js-cookie": "3.0.5",
|
|
27
27
|
"next": "15.5.6",
|
|
28
28
|
"qs": "6.14.0",
|
|
29
|
-
"@ichaingo/logger": "1.4.
|
|
30
|
-
"@ichaingo/token": "1.4.
|
|
29
|
+
"@ichaingo/logger": "1.4.92",
|
|
30
|
+
"@ichaingo/token": "1.4.92"
|
|
31
31
|
}
|
|
32
32
|
}
|