@@ -2,34 +2,34 @@ const express = require("express");
2
2
const app = express ( ) ;
3
3
const PORT = 3000 ;
4
4
5
- app . use ( function ( req , res , next ) {
5
+ app . use ( ( req , res , next ) => {
6
6
console . log ( "common middleware function was called!" ) ;
7
7
next ( ) ;
8
8
} ) ;
9
9
10
- app . use ( "/users" , function ( req , res , next ) {
10
+ app . use ( "/users" , ( req , res , next ) => {
11
11
console . log ( "middleware function for /users was called!" ) ;
12
12
next ( ) ;
13
13
} ) ;
14
14
15
15
// this will only be called for POST requests
16
- app . post ( "/users" , function ( req , res , next ) {
16
+ app . post ( "/users" , ( req , res , next ) => {
17
17
console . log ( "second middleware function for /users was called!" ) ;
18
18
next ( ) ;
19
19
} ) ;
20
20
21
21
// this will only be called for GET requests
22
- app . get ( "/users" , function ( req , res , next ) {
22
+ app . get ( "/users" , ( req , res , next ) => {
23
23
console . log ( "third middleware function for /users was called!" ) ;
24
24
next ( ) ;
25
25
} ) ;
26
26
27
- app . get ( "/users" , function ( req , res ) {
27
+ app . get ( "/users" , ( req , res ) => {
28
28
console . log ( "users list was shown" ) ;
29
29
res . send ( "Here is a list of users:...." ) ;
30
30
} ) ;
31
31
32
- app . get ( "/books" , function ( req , res ) {
32
+ app . get ( "/books" , ( req , res ) => {
33
33
console . log ( "books list was shown" ) ;
34
34
res . send ( "Here is a list of books:...." ) ;
35
35
} ) ;
0 commit comments