zengyicheng 1 tahun lalu
induk
melakukan
5462292d79
1 mengubah file dengan 27 tambahan dan 4 penghapusan
  1. 27 4
      ssti.js

+ 27 - 4
ssti.js

@@ -60,22 +60,45 @@ router.post('/testApi', function(req, res, next) {
         hostname: 'cxcy.ssti.net.cn',
         port: 443,
         path: "/sso/api",
-        method: req.method,
+        method: 'GET', // 请求方法
         headers: req.headers
     };
 
+    // 发送HTTP请求
     const backendReq = https.request(options, (res) => {
-        // 处理响应
-        res.on('data', (data) => {
-            console.log(data.toString());
+        let data = '';
+
+        // 接收响应数据
+        res.on('data', (chunk) => {
+            data += chunk;
+        });
+
+        // 响应结束时处理数据
+        res.on('end', () => {
+            console.log(data); // 输出获取到的数据
         });
     });
 
+    // 处理请求错误
     backendReq.on('error', (error) => {
         console.error(error);
     });
 
+    // 发送请求
     backendReq.end();
+
+    // const backendReq = https.request(options, (res) => {
+    //     // 处理响应
+    //     res.on('data', (data) => {
+    //         console.log(data.toString());
+    //     });
+    // });
+
+    // backendReq.on('error', (error) => {
+    //     console.error(error);
+    // });
+
+    // backendReq.end();
 })
 
 //消息与任务接口