28 lines
713 B
JavaScript
28 lines
713 B
JavaScript
async function testApiDebug() {
|
|
console.log('🧪 調試 API 錯誤...\n');
|
|
|
|
try {
|
|
// 測試用戶列表 API
|
|
console.log('1. 測試用戶列表 API...');
|
|
const response = await fetch('http://localhost:3000/api/admin/users');
|
|
|
|
console.log('狀態碼:', response.status);
|
|
console.log('狀態文本:', response.statusText);
|
|
|
|
const data = await response.text();
|
|
console.log('響應內容:', data);
|
|
|
|
if (response.ok) {
|
|
const jsonData = JSON.parse(data);
|
|
console.log('✅ API 成功:', jsonData);
|
|
} else {
|
|
console.log('❌ API 失敗');
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('❌ 測試過程中發生錯誤:', error);
|
|
}
|
|
}
|
|
|
|
testApiDebug();
|