Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Receiving Data from Client | Section
/
Building APIs with Express.js

bookReceiving 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に質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

セクション 1.  9
some-alt