Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Built-in Middleware | Express.js Framework
Node.js Express: API & CLI Apps
course content

Conteúdo do Curso

Node.js Express: API & CLI Apps

Node.js Express: API & CLI Apps

1. Introduction
2. Console Applications
3. Express.js Framework
4. Developing REST API

bookBuilt-in Middleware

In Express.js, you can access a set of built-in middleware functions designed to simplify everyday tasks in web development. These middleware functions can significantly streamline processes like parsing incoming data and serving static files. Here are some key built-in middleware functions:

express.json()

The express.json() middleware is used to parse incoming JSON data from requests with a JSON payload. It automatically parses the JSON data and makes it accessible through the req.body property for further processing.

express.urlencoded()

The express.urlencoded() middleware parses incoming URL-encoded data from forms submitted via POST requests. It adds the parsed data to the req.body property.

Note

The { extended: true } option allows for handling more complex data in form submissions.

express.static()

The express.static() middleware serves static files, such as HTML, CSS, JavaScript, and images, from a specified directory. It's a valuable tool for serving assets like stylesheets and client-side scripts.

Utilizing these built-in middleware functions allows you to streamline the process of handling data and serving static files in your Express.js applications.

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 8
some-alt