Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ app.get("/messages", (request, response) => {

app.post("/send", (request, response) => {
messages.push(request.body.message);
response.send();
response.sendStatus(201); // Created(新しいメッセージを作成)
});

app.listen(3000);
6 changes: 3 additions & 3 deletions docs/3-web-servers/07-fetch-api-post/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ document.getElementById("search-button").onclick = async () => {

<video src={chatAppVideo} controls muted />

サーバー側では、これまでのメッセージを保存する配列`messages`を用意しましょう。`/messages`に対するGETリクエストを受けたとき、配列`messages`をJSON形式で返すようにしてください。また、`/send`に対するPOSTリクエストを受けたとき、`Array#push`メソッドで受け取ったメッセージを配列`messages`に追加するようにしてください
サーバー側では、これまでのメッセージを保存する配列`messages`を用意しましょう。`/messages`に対するGETリクエストを受けたとき、配列`messages`をJSON形式で返すようにしてください。また、`/send`に対するPOSTリクエストを受けたとき、`Array#push`メソッドで受け取ったメッセージを配列`messages`に追加して、適切な<Term>ステータスコード</Term>を返すようにしてください

```javascript title="main.mjsの抜粋 (サーバーとして動作するJavaScript)"
const messages = [];
Expand All @@ -294,7 +294,7 @@ app.get("/messages", (request, response) => {

app.post("/send", (request, response) => {
// 受け取ったメッセージをmessagesに追加
response.send();
response.sendStatus(201); // Created(新しいメッセージを作成)
});
```

Expand Down Expand Up @@ -327,7 +327,7 @@ app.get("/messages", (request, response) => {

app.post("/send", (request, response) => {
messages.push(request.body.message);
response.send();
response.sendStatus(201); // Created(新しいメッセージを作成)
});

app.listen(3000);
Expand Down
2 changes: 1 addition & 1 deletion docs/3-web-servers/08-database/_samples/forum/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ app.get("/posts", async (request, response) => {

app.post("/send", async (request, response) => {
await client.post.create({ data: { message: request.body.message } });
response.send();
response.sendStatus(201); // Created(新しいメッセージを作成)
});

app.listen(3000);
2 changes: 1 addition & 1 deletion docs/3-web-servers/08-database/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ app.post("/send", async (request, response) => {
```javascript title="main.mjsの抜粋 (サーバーとして動作するJavaScript)"
app.post("/send", async (request, response) => {
await client.post.create({ data: { message: request.body.message } });
response.send();
response.sendStatus(201); // Created(新しいメッセージを作成)
});
```

Expand Down
2 changes: 1 addition & 1 deletion src/components/Term/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ export default {
httpStatusCode: {
name: "ステータスコード (HTTP)",
definition:
"HTTPレスポンスに含まれる、リクエストの処理結果を表す3桁の数値。200番台は成功、400番台はクライアント側の問題での失敗、500番台はサーバー側の問題での失敗を表す。代表的なものに200 (OK)、400 (Bad Request)、401 (Unauthorized)、404 (Not Found)、500 (Internal Server Error)がある。",
"HTTPレスポンスに含まれる、リクエストの処理結果を表す3桁の数値。200番台は成功、400番台はクライアント側の問題での失敗、500番台はサーバー側の問題での失敗を表す。代表的なものに200 (OK)、201 (Created)、400 (Bad Request)、401 (Unauthorized)、404 (Not Found)、500 (Internal Server Error)がある。",
referencePage: "/docs/web-servers/fetch-api-post/",
},
npxCommand: {
Expand Down