• 카테고리

    질문 & 답변
  • 세부 분야

    풀스택

  • 해결 여부

    미해결

미들웨어 get으로 처리하는 방법

22.09.01 22:59 작성 조회수 87

0

app.use((req, res, next) => {
    console.log('1 요청에 실행');
    next();
}).use((req, res, next) => {
    console.log('2 요청에 실행');
    next();
}).use((req, res, next) => {
    console.log('3 요청에 실행');
    next();
})
app.get('*/', (req, res, next) => {
    console.log('1 요청에 실행');
    next();
}).get('*/', (req, res, next) => {
    console.log('2 요청에 실행');
    next();
}).get('*/', (req, res, next) => {
    console.log('3 요청에 실행');
    next();
})

위에 처럼 use로 되어있는 미들웨어를 get으로 처리해도 똑같이 돌아가는데 둘의 차이점이 있나요?

답변 1

답변을 작성해보세요.

0

use로 할 경우 get이 아닌 post put patch 등 모든 라우터에 해당됩니다.