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