refactor(docs): 更新API接口文档结构,优化环境配置说明并移除冗余文件
This commit is contained in:
32
test-orders.js
Normal file
32
test-orders.js
Normal file
@@ -0,0 +1,32 @@
|
||||
const axios = require('axios');
|
||||
|
||||
async function testOrders() {
|
||||
try {
|
||||
// 使用已知的有效测试账户
|
||||
const loginResponse = await axios.post('http://localhost:4330/api/auth/login', {
|
||||
username: 'admin',
|
||||
password: 'admin123'
|
||||
}, {
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
const token = loginResponse.data.data.token;
|
||||
console.log('登录成功,Token:', token);
|
||||
|
||||
// 测试订单查询
|
||||
const ordersResponse = await axios.get('http://localhost:4330/api/orders', {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
|
||||
console.log('订单查询成功:', JSON.stringify(ordersResponse.data, null, 2));
|
||||
|
||||
} catch (error) {
|
||||
console.error('测试失败:', error.response?.data || error.message);
|
||||
}
|
||||
}
|
||||
|
||||
// 等待服务器启动
|
||||
setTimeout(testOrders, 3000);
|
||||
Reference in New Issue
Block a user