| Level Navigation: 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⚡ | 28⚡ | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39⚡ | 40⚡ |
Create a new route called “Happy Birthday” that returns JSON. Add a GET /happy-birthday route (or similar path) that returns a JSON object with:
name: a person’s nameage: their agegreeting: a birthday greeting messageUse res.json() to send the response. Test it in Postman to see the JSON formatted response.
app.get('/happy-birthday', (req, res) => {
res.json({
name: 'Alice',
age: 25,
greeting: 'Happy Birthday! 🎉'
});
});
Content-Type: application/json header are both correct.