Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Creating Data with POST for API | Section
Building APIs with Express.js

bookCreating Data with POST for API

メニューを表示するにはスワイプしてください

POST endpoints are used to create new data.

The client sends data in the request body, and the server processes it and stores it.

let users = [
  { id: 1, name: 'John' }
];

app.post('/users', (req, res) => {
  const newUser = req.body;

  users.push(newUser);

  res.json(newUser);
});

The server receives the data through req.body and adds it to the collection.

Example request body:

{ "id": 2, "name": "Anna" }

After sending this request, the new user is added.

POST endpoints are used whenever you need to create new records in your application.

すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1.  13

AIに質問する

expand

AIに質問する

ChatGPT

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

セクション 1.  13
some-alt