From 3b826cbf1275f55717f13f71f78c75504183ec56 Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期四, 31 七月 2025 16:22:28 +0800
Subject: [PATCH] 更新到大连仁人inbody分析仪接口
---
thirdPartyApi.js | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/thirdPartyApi.js b/thirdPartyApi.js
index 112e0fe..15d701b 100644
--- a/thirdPartyApi.js
+++ b/thirdPartyApi.js
@@ -3,7 +3,8 @@
const path = require('path');
const FormData = require('form-data');
const logger = require(path.resolve(__dirname, 'logger'));
-const BASIC_API = 'https://hemobs.icoldchain.cn/'
+// const BASIC_API = 'https://hemobs.icoldchain.cn/'
+const BASIC_API = 'https://backend.ihemodialysis.com'
// const BASIC_API = 'http://testbs.ihemodialysis.com/'
let cachedToken = null;
let tokenExpiresAt = null;
@@ -44,6 +45,7 @@
const { data, expires_in } = await getAccessToken();
cachedToken = data;
tokenExpiresAt = Date.now() + (expires_in - 60) * 1000; // 提前 60 秒刷新 token
+ console.log(`获取新的 token: ${cachedToken}, 过期时间: ${new Date(tokenExpiresAt)}`);
return cachedToken;
}
@@ -78,12 +80,24 @@
}
}
-// 发起第三方 API 请求
+/**
+ *
+ * @param {*} url rul
+ * @param {*} method 方法
+ * @param {*} headers 表头
+ * @param {*} data json数据
+ * @param {*} queryParams 查询条件
+ * @param {*} pathParams 路由条件
+ * @returns
+ */
async function fetchThirdPartyData(url, method = 'GET', headers = {}, data = null, queryParams = {}, pathParams = {}) {
try {
+ console.log(`打包token 请求头url${url},data=${JSON.stringify(data)}`)
+ console.log(`pathParams 请求头url${JSON.stringify(pathParams)}`)
const token = await getCachedOrNewToken();
const fullUrl = buildUrl(url, pathParams);
logger.info(`打包token 请求头url${fullUrl},data=${JSON.stringify(data)}`)
+
const response = await axios({
url: fullUrl,
method,
@@ -92,7 +106,7 @@
Authorization: `Bearer ${token}`
},
params: queryParams, // 查询字符串参数
- data // 请求体参数
+ data:data// 请求体参数
});
return response.data;
--
Gitblit v1.8.0