Spaces:
Sleeping
Sleeping
| const express = require('express'); | |
| const app = express(); | |
| app.use(express.json()); | |
| app.post('/shipping-rates', (req, res) => { | |
| // Compute the weight of all items | |
| console.log(req.body); | |
| const weight = req.body.rate.items.reduce((acc, item) => acc + item.grams, 0); | |
| res.json({ "rates": [ { | |
| "service_name": "Transporteur privée", | |
| "service_code": "CA", | |
| "total_price": "1295", | |
| "description": "", | |
| "currency": "EUR" | |
| }, | |
| ]}); | |
| }); | |
| app.listen(3000, () => console.log('Shipping API running on port 3000')); |