Receiving Data from Client
メニューを表示するにはスワイプしてください
When a client sends data to the server, it is usually included in the request body.
To read this data in Express, you need to enable JSON parsing using middleware:
app.use(express.json());
After that, you can access incoming data using req.body.
app.post('/users', (req, res) => {
const user = req.body;
res.json(user);
});
If a client sends:
{ "name": "John", "age": 25 }
You can access it like this:
- Name:
req.body.name; - Age:
req.body.age.
This is commonly used when creating or updating data in backend applications.
すべて明確でしたか?
フィードバックありがとうございます!
セクション 1. 章 9
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください
セクション 1. 章 9