@be-link/pos-cli-nodejs 0.0.149 → 0.0.151

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/pos/http.js +6 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@be-link/pos-cli-nodejs",
3
- "version": "0.0.149",
3
+ "version": "0.0.151",
4
4
  "description": "正向订单服务Nodejs客户端",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/pos/http.js CHANGED
@@ -9,7 +9,8 @@ const uuid_1 = require("uuid");
9
9
  const BizError_1 = __importDefault(require("../errors/BizError"));
10
10
  const SystemError_1 = __importDefault(require("../errors/SystemError"));
11
11
  const axios_retry_1 = __importDefault(require("axios-retry"));
12
- (0, axios_retry_1.default)(axios_1.default, {
12
+ const axiosInstance = axios_1.default.create();
13
+ (0, axios_retry_1.default)(axiosInstance, {
13
14
  retries: 1,
14
15
  retryCondition(error) {
15
16
  return error.message.includes('getaddrinfo ENOTFOUND') || [502, 503].includes(error.response.status);
@@ -26,9 +27,11 @@ async function callApi(url, ...request) {
26
27
  const requestId = (0, uuid_1.v4)();
27
28
  try {
28
29
  console.info(`准备发起POS请求[${requestId}]: ${url}, 参数: ${JSON.stringify(request)}`);
29
- const response = await axios_1.default.post(url, request[0], {
30
+ const response = await axiosInstance.post(url, request[0], {
30
31
  headers: {
31
- 'X-Request-Id': requestId
32
+ 'X-Request-Id': requestId,
33
+ 'x-belink-accessType': 'authorizationTokenInside',
34
+ 'x-belink-authorization': process.env.authorizationTokenInside || ""
32
35
  }
33
36
  });
34
37
  const responseData = response.data;