@noah-libjs/request 0.0.56 → 0.0.57
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/Request.d.ts +1 -1
- package/dist/index.js +5 -7
- package/package.json +3 -3
package/dist/Request.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare class Request extends EventEmitter<{
|
|
|
14
14
|
static CONFIG: {
|
|
15
15
|
successCode: (string | number)[];
|
|
16
16
|
};
|
|
17
|
-
static
|
|
17
|
+
static req_log: MyLog;
|
|
18
18
|
static checkRTCode(res?: AxiosResponse<any>): boolean;
|
|
19
19
|
static genErrMsg(res?: AxiosResponse<any>, error?: AxiosError): string;
|
|
20
20
|
static createErr(res?: AxiosResponse<any>, error?: AxiosError): IRequest_ResponseError;
|
package/dist/index.js
CHANGED
|
@@ -131,14 +131,12 @@ var Request = /*#__PURE__*/function (_EventEmitter) {
|
|
|
131
131
|
var ins = axios.create(config);
|
|
132
132
|
var _onErr = function _onErr(e) {
|
|
133
133
|
_this2.emit('error', e);
|
|
134
|
-
config.logger && Request.
|
|
134
|
+
config.logger && Request.req_log.error(e);
|
|
135
135
|
return onRejected(e);
|
|
136
136
|
};
|
|
137
137
|
ins.interceptors.request.use(function (config) {
|
|
138
138
|
var _a;
|
|
139
|
-
|
|
140
|
-
config: config
|
|
141
|
-
});
|
|
139
|
+
config.logger && Request.req_log.log('request', config);
|
|
142
140
|
if (config.pure_req) return onRequest(config);
|
|
143
141
|
var headers = (_a = config.headers) !== null && _a !== void 0 ? _a : config.headers = {};
|
|
144
142
|
if (!config.ignore_x_arg) {
|
|
@@ -168,7 +166,7 @@ var Request = /*#__PURE__*/function (_EventEmitter) {
|
|
|
168
166
|
unboxing = config.unboxing;
|
|
169
167
|
_this2.displayMsg(response);
|
|
170
168
|
if (Request.checkRTCode(response)) {
|
|
171
|
-
logger && Request.
|
|
169
|
+
logger && Request.req_log.log({
|
|
172
170
|
url: url,
|
|
173
171
|
data: data,
|
|
174
172
|
params: params,
|
|
@@ -188,7 +186,7 @@ var Request = /*#__PURE__*/function (_EventEmitter) {
|
|
|
188
186
|
var e = Request.createErr(response);
|
|
189
187
|
return _onErr(e);
|
|
190
188
|
}, function (error) {
|
|
191
|
-
Request.
|
|
189
|
+
Request.req_log.error('请求出错:', {
|
|
192
190
|
error: error
|
|
193
191
|
});
|
|
194
192
|
_this2.displayMsg(error.response);
|
|
@@ -273,7 +271,7 @@ Object.defineProperty(Request, "CONFIG", {
|
|
|
273
271
|
successCode: [200, 1, 0, '200']
|
|
274
272
|
}
|
|
275
273
|
});
|
|
276
|
-
Object.defineProperty(Request, "
|
|
274
|
+
Object.defineProperty(Request, "req_log", {
|
|
277
275
|
enumerable: true,
|
|
278
276
|
configurable: true,
|
|
279
277
|
writable: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noah-libjs/request",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.57",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@noah-libjs/utils": "^0.0.
|
|
24
|
+
"@noah-libjs/utils": "^0.0.57",
|
|
25
25
|
"axios": "^0.26.1",
|
|
26
26
|
"store": "2.x"
|
|
27
27
|
},
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"keywords": [],
|
|
33
33
|
"author": "",
|
|
34
34
|
"license": "MIT",
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "09002308afa59b067c54feba380fcde3b3c4bd11"
|
|
36
36
|
}
|