1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| const express = require('express'); const bodyParser = require('body-parser');
const app = express(); app.use(bodyParser.urlencoded({ extended: false })); app.use(bodyParser.json());
app.post('/api/data', (req, res) => { const requestData = req.body; const responseData = { message: 'Data received successfully', data: [] }; res.json(responseData); });
const port = 3000; app.listen(port, () => { console.log(`Server is listening on port ${port}`); });
|