Files
AIclinicalresearch/测试API.bat
AI Clinical Dev Team b9cb173eb6 fix: resolve double data unwrapping issue in API calls
Issue: projectApi and agentApi were unwrapping response.data twice:
1. request interceptor returns response.data
2. API functions returned response.data again (undefined)

This caused all API calls to fail silently with 'response.success' being undefined.

Fixed:
- projectApi: Removed redundant .data access
- agentApi: Removed redundant .data access

All API functions now correctly return the backend response:
{ success: true, data: [...] }

This fixes:
- '鑾峰彇椤圭洰鍒楄〃澶辫触' error on page load
- '鍒涘缓椤圭洰澶辫触' error when creating projects
- Any other API call failures
2025-10-10 21:33:38 +08:00

90 lines
2.2 KiB
Batchfile
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@echo off
chcp 65001 >nul
echo ========================================
echo API测试工具
echo ========================================
echo.
echo [测试1] 后端健康检查
echo URL: http://localhost:3001/health
curl -s http://localhost:3001/health
if errorlevel 1 (
echo.
echo ❌ 后端服务未响应
echo 解决方案: cd backend ^&^& npm run dev
goto :end
) else (
echo.
echo ✅ 后端服务正常
)
echo.
echo ----------------------------------------
echo.
echo [测试2] 获取项目列表
echo URL: http://localhost:3001/api/v1/projects
curl -s http://localhost:3001/api/v1/projects
if errorlevel 1 (
echo.
echo ❌ 获取项目列表失败
) else (
echo.
echo ✅ 获取项目列表成功
)
echo.
echo ----------------------------------------
echo.
echo [测试3] 获取智能体列表
echo URL: http://localhost:3001/api/v1/agents
curl -s http://localhost:3001/api/v1/agents
if errorlevel 1 (
echo.
echo ❌ 获取智能体列表失败
) else (
echo.
echo ✅ 获取智能体列表成功
)
echo.
echo ----------------------------------------
echo.
echo [测试4] 创建测试项目
echo URL: http://localhost:3001/api/v1/projects
echo 正在创建项目...
curl -X POST http://localhost:3001/api/v1/projects -H "Content-Type: application/json" -d "{\"name\":\"API测试项目\",\"background\":\"这是通过脚本创建的测试项目\",\"researchType\":\"observational\"}"
if errorlevel 1 (
echo.
echo ❌ 创建项目失败
) else (
echo.
echo ✅ 创建项目成功
)
echo.
echo ----------------------------------------
echo.
echo [测试5] 前端服务检查
echo URL: http://localhost:3000
curl -s http://localhost:3000 >nul 2>&1
if errorlevel 1 (
echo ❌ 前端服务未响应
echo 解决方案: cd frontend ^&^& npm run dev
) else (
echo ✅ 前端服务正常
)
echo.
:end
echo ========================================
echo 测试完成
echo ========================================
echo.
echo 如果所有测试都通过,但浏览器仍有问题:
echo 1. 按 Ctrl + Shift + R 强制刷新浏览器
echo 2. 查看浏览器控制台F12的错误信息
echo 3. 查看解决方案-前端获取数据失败.md
echo.
pause