Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Introduction to Middleware | Section
Building APIs with Express.js

bookIntroduction to Middleware

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

Middleware is a function that runs between receiving a request and sending a response.

It has access to the request, the response, and a special function called next.

app.use((req, res, next) => {
  console.log('Request received');
  next();
});

When a request comes in, middleware runs first. After it finishes, it calls next() to pass control to the next step.

The flow looks like this:

Request → Middleware → Route → Response

Middleware is used to process requests before they reach your route logic.

Common use cases include:

  • Logging Requests;
  • Parsing Data;
  • Checking Authentication.
question mark

What does next() do in middleware?

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

すべて明確でしたか?

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

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

セクション 1.  10

AIに質問する

expand

AIに質問する

ChatGPT

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

セクション 1.  10
some-alt