Created
December 14, 2020 08:54
-
-
Save Rooarii/fc0dc3a8fa817ad971900ae31ff4af7f to your computer and use it in GitHub Desktop.
Middlewares dans Express
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express =require('express'); | |
const router = express.Router(); | |
router.get('/', (req, res)=>{ | |
res.send('Hello 🌎, welcome on Aliens 👽 API!') | |
}); | |
let helloMiddleware = (req, res, next) =>{ | |
console.log('hello middleware'); | |
next(); | |
} | |
let helloWorld = (req, res) =>{ | |
res.send('hello world'); | |
} | |
router.use(helloMiddleware, helloWorld); | |
router.get('/superMiddleware', (req,res)=>{ | |
// console.log('hello middleware') | |
}) | |
module.exports = router; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment