minishouyin/test/test-create-order.js

31 lines
717 B
JavaScript
Raw Normal View History

2025-11-12 11:35:57 +08:00
const axios = require('axios');
async function testCreateOrder() {
try {
const response = await axios.post('http://localhost:3001/api/orders', {
items: [
{
product_id: 1,
quantity: 2
}
],
total_amount: 7.00,
paid_amount: 7.00,
payment_method: 'cash'
}, {
headers: {
'Content-Type': 'application/json'
}
});
console.log('Order created successfully:', response.data);
} catch (error) {
if (error.response) {
console.error('Error creating order:', error.response.status, error.response.data);
} else {
console.error('Error creating order:', error.message);
}
}
}
testCreateOrder();