const express = require('express'); const app = express(); const port = 3000; // Middleware untuk parsing JSON app.use(express.json()); // Contoh data yang akan diberikan sebagai output const data = [ { id: 1, name: 'John Doe', email: 'john@example.com' }, { id: 2, name: 'Jane Smith', email: 'jane@example.com' }, { id: 3, name: 'Michael Johnson', email: 'michael@example.com' } ]; // Endpoint GET untuk mendapatkan semua data app.get('/api/data', (req, res) => { res.json(data); }); app.listen(port, () => { console.log(`Server berjalan di http://localhost:${port}`); });