Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Request and Response Basics | Section
/
Building APIs with Express.js

bookRequest and Response Basics

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

Every route in Express works with two objects: the request and the response.

The req object contains information about the incoming request. The res object is used to send a response back to the client.

const express = require('express');

const app = express();

app.get('/', (req, res) => {
  console.log(req.method);
  res.send('Hello');
});

app.listen(3000);

The request object can provide useful details about the request:

  • Request Method: req.method;
  • Request URL: req.url.

The response object is used to send data back:

res.send('Hello');

Once a response is sent, the request is completed.

Understanding these two objects is essential because every backend action starts with a request and ends with a response.

question mark

Which object is used to send data back to the client?

正しい答えを選んでください

すべて明確でしたか?

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

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

セクション 1.  5

AIに質問する

expand

AIに質問する

ChatGPT

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

セクション 1.  5
some-alt