Raja Muhammad Asher
Raja Muhammad Asher

Raja Muhammad Asher

What is routing and how routing works in
Express.js?

Photo by Joan Gamell on Unsplash

What is routing and how routing works in Express.js?

Raja Muhammad Asher's photo
Raja Muhammad Asher
·Jul 18, 2022·

1 min read

Routing refers to determining how an application responds to a client request to a particular endpoint, which is a URI (or path) and a specific HTTP request method (GET, POST, and so on).

Each route can have one or more handler functions, which are executed when the route is matched.

The following example illustrates defining simple route. Respond with Hello World! on the homepage:

app.get('/', (req, res) => {
  res.send('Hello World!')
})

Source:

Express Basic Routing. expressjs.com/en/starter/basic-routing.html.

 
Share this