Page 234 - Nodejs 교과서 개정2판
P. 234
router.get('/', function(req, res, next) {
next('route');
}, function(req, res, next) {
console.log('실행되지 않습니다');
next();
}, function(req, res, next) {
console.log('실행되지 않습니다');
next();
});
router.get('/', function(req, res) {
console.log('실행됩니다');
res.send('Hello, Express');
});
ਤ ઁۢ э ࣗ ۄఠܳ ৈ۞ ѐ ٜ݅যب ؾפ ۄఠо ݻ ѐٚ рী next()ܳ ഐೞݶ
ٜਝযо प೯ؾפ
ߣ૩ ۄఠ ߣ૩ ٜਝযীࢲ next() न next route')ܳ ഐ೮णפ ҃ীח ف ߣ૩ ࣁ
ߣ૩ ٜਝযо प೯غ ঋणפ न ࣗ৬ ੌೞח ۄఠ۽ ֈযцפ
ਬਊೠ ೞա ؊ णפ ۄఠ ࣗীח ӏഅधਸ ࠺܃ೠ ౠࣻ ಁఢਸ ࢎਊೡ ࣻ णפ ৈ۞ о
ಁఢ ݅ ॳח ಁఢ ೞա݅ ঌইࠁѷणפ ۄ ݒѐ߸ࣻۄҊ ܻࠛח ಁఢੑפ
router.get('/user/:id', function(req, res) {
console.log(req.params, req.query);
});
ࣗী :idо חؘਃ ޙ Ӓ۽ :idܳ ೞח Ѫ ইתפ ࠗ࠙ীח ܲ чਸ ֍ਸ ࣻ णפ /
users/1ա /users/123 ١ ਃب ۄఠо ܻೞѱ ؾפ ߑध :idী ೧ೞח 1ա 12
3ਸ ઑഥೡ ࣻ ח ݴ req.params ё উী ٜয णפ :idݶ req.params.id۽ :typeݶ req.p
arams.typeਵ۽ ઑഥೡ ࣻ णפ
ױ ಁఢਸ ࢎਊೡ ٸ ೡ णפ ੌ߈ ۄఠࠁ ٍী ਤ೧ঠ ೠח Ѫੑפ নೠ ۄఠ
ܳ ইܰח ৬ੌ٘٘ ೡਸ ೞ۽ ੌ߈ ۄఠࠁח ٍী ਤ೧ঠ ܲ ۄఠܳ ߑ೧ೞ ঋणפ
router.get('/user/:id', function(req, res) {
console.log('얘만 실행됩니다.');
});
router.get('/user/like', function(req, res) {