import express from 'express' import axios from 'axios' const app = express() app.get('/posts', async(req, res) => { try { const result = await axios.get('https://jsonplaceholder.typicode.com/posts') res.json(result.data) } catch (error) { res.status(500).json({ error: 'Fetch failed.'}) } }) app.listen(3000, () => { console.log('Server running at port 3000') })