Files
nxxmdata/insurance_admin-system/test-frontend-api.js
2025-09-30 17:41:21 +08:00

40 lines
1.1 KiB
JavaScript
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.

// 测试前端API调用
const testFrontendAPI = async () => {
try {
console.log('开始测试前端API调用...');
// 模拟前端API调用
const response = await fetch('http://49.51.70.206:3000/api/policies?page=1&pageSize=10', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
});
console.log('API响应状态:', response.status);
if (!response.ok) {
const errorData = await response.json();
console.error('API错误:', errorData);
return;
}
const data = await response.json();
console.log('API响应数据:', data);
if (data.status === 'success' && data.data) {
console.log('✅ API调用成功返回', data.data.length, '条保单数据');
console.log('第一条保单数据:', data.data[0]);
} else {
console.log('❌ API响应格式不正确');
}
} catch (error) {
console.error('❌ API调用失败:', error);
}
};
// 在浏览器控制台中运行
console.log('请在浏览器控制台中运行: testFrontendAPI()');