Request 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.
すべて明確でしたか?
フィードバックありがとうございます!
セクション 1. 章 5
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください
セクション 1. 章 5