31 lines
717 B
JavaScript
31 lines
717 B
JavaScript
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(); |