Using res.json for JSON responses in Express
📖 Scenario: You are building a simple Express server that sends JSON data to clients. This is common when creating APIs that share data with web or mobile apps.
🎯 Goal: Create an Express server that responds with JSON data using res.json(). You will set up data, configure a route, send the JSON response, and complete the server setup.
📋 What You'll Learn
Create a data object with exact key-value pairs
Set up an Express app and a port variable
Create a GET route that sends the data as JSON using res.json()
Start the server listening on the specified port
💡 Why This Matters
🌍 Real World
APIs often send data as JSON to web or mobile apps. Using res.json() in Express is a simple way to send this data.
💼 Career
Backend developers use Express and res.json() to build APIs that communicate data efficiently and clearly.
Progress0 / 4 steps