1
나는 익스프레스를 사용하고있다.왜 항상 첫 번째 길을 치는거야
router.get('/:id', function (req, res, next) {
router.get('/search', function (req, res, next) {
내가 두 번째 대신 주먹 경로를 명중 http://localhost:3000/users/[email protected]
을 GET 호출 할 때마다 :
나는이 개 경로를 가지고?
어떻게 변경해야합니까?
당신은 순서를 바꿀 수 있기 때문에 앱은'/ search '가 일치하지 않을 때'/ : id' 만 체크합니다. 또는 Express는 [매개 변수가있는 형식 제공] (https://www.npmjs.com/package/path-to-regexp#custom-match-parameters)을 지원하는'path-to-regexp'를 사용합니다. '/ : id (\ d +)'(오직 숫자로'id'가 매치 됨). –