eprolo-cli 1.0.49 → 1.0.51
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/bin/eprolo-cli.js +28 -28
- package/package.json +1 -1
package/bin/eprolo-cli.js
CHANGED
|
@@ -86,42 +86,42 @@ function postJson(url, body, headers = {}) {
|
|
|
86
86
|
// ---------------------------------------------------------------------------
|
|
87
87
|
|
|
88
88
|
async function postJsonWithRetry(url, body, config) {
|
|
89
|
-
|
|
89
|
+
let headers = {};
|
|
90
90
|
if (config.accessToken) headers["accessToken"] = `${config.accessToken}`;
|
|
91
91
|
|
|
92
92
|
let result = await postJson(url, body, headers);
|
|
93
93
|
|
|
94
|
-
if (result.statusCode === 401) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (result.
|
|
94
|
+
// if (result.statusCode === 401) {
|
|
95
|
+
// // 刷新 token
|
|
96
|
+
// const refreshRes = await postJson(REFRESH_API, {
|
|
97
|
+
// accessToken: config.accessToken,
|
|
98
|
+
// accountId: config.accountId,
|
|
99
|
+
// shopId: config.shopId
|
|
100
|
+
// });
|
|
101
|
+
|
|
102
|
+
// if (refreshRes.statusCode >= 200 && refreshRes.statusCode < 300 && refreshRes.data.accessToken) {
|
|
103
|
+
// // 更新凭据文件
|
|
104
|
+
// config.accessToken = refreshRes.data.accessToken;
|
|
105
|
+
// if (refreshRes.data.account) config.account = refreshRes.data.account;
|
|
106
|
+
// writeConfig(config);
|
|
107
|
+
|
|
108
|
+
// // 用新 token 重试
|
|
109
|
+
// headers["authorization"] = `Bearer ${config.accessToken}`;
|
|
110
|
+
// result = await postJson(url, body, headers);
|
|
111
|
+
// } else {
|
|
112
|
+
// const err = new Error("Token 刷新失败,请重新登录授权");
|
|
113
|
+
// err.response = refreshRes.data;
|
|
114
|
+
// throw err;
|
|
115
|
+
// }
|
|
116
|
+
// }
|
|
117
|
+
|
|
118
|
+
if (result.code !== 0) {
|
|
119
119
|
const err = new Error(`HTTP ${result.statusCode}`);
|
|
120
120
|
err.response = result.data;
|
|
121
121
|
throw err;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
return result
|
|
124
|
+
return result;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
// ---------------------------------------------------------------------------
|
|
@@ -190,7 +190,7 @@ async function queryOrders() {
|
|
|
190
190
|
process.exit(1);
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
const data = await postJsonWithRetry(ORDERS_API, {}, config);
|
|
193
|
+
const data = await postJsonWithRetry(ORDERS_API, {id:'1'}, config);
|
|
194
194
|
console.log(JSON.stringify(data, null, 2));
|
|
195
195
|
process.exit(0);
|
|
196
196
|
}
|
package/package.json
CHANGED