Sending JSON Responses
Swipe to show menu
In backend development, data is usually sent in JSON format.
JSON is a structured way to represent data. It looks like a JavaScript object but is used for communication between systems.
In Express, you can send JSON using res.json():
app.get('/user', (req, res) => {
res.json({
name: 'John',
age: 25
});
});
This sends a structured response that can be easily used by the frontend.
JSON is commonly used because it is simple, readable, and supported by all modern applications.
Everything was clear?
Thanks for your feedback!
Section 1. Chapter 6
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Section 1. Chapter 6