Inflearn brand logo image

인프런 커뮤니티 질문&답변

박건형님의 프로필 이미지
박건형

작성한 질문수

Node.js - Express

Express 미들웨어 만들기

왜 에러가 뜰까요...

작성

·

21

0

app.get('*',function(req, res, next){
  fs.readdir('./data', function(error, filelist){
    req.list = filelist;
    next();
  });
});

app.post('/create_process', (req, res)=>{
  console.log(req.list);
  var post = req.body;
          var title = post.title;
           var description = post.description;
          fs.writeFile(`data/${title}`, description, 'utf8', function(err){
             res.writeHead(302, {Location: `/?id=${title}`});
             res.end();
          })
});

이렇게 코드를 영상과 동일하게 작성했는데 왜 인지 모르게 자꾸 localhost:3000에서 튕기는데 그 이유를 도무지 모르겠습니다...

0|main | TypeError: Missing parameter name at 1: https://git.new/pathToRegexpError

0|main | at name (C:\Users\kunhy\node_modules\path-to-regexp\dist\index.js:73:19)

0|main | at lexer (C:\Users\kunhy\node_modules\path-to-regexp\dist\index.js:91:27)

0|main | at lexer.next (<anonymous>)

0|main | at Iter.peek (C:\Users\kunhy\node_modules\path-to-regexp\dist\index.js:106:38)

0|main | at Iter.tryConsume (C:\Users\kunhy\node_modules\path-to-regexp\dist\index.js:112:28)

0|main | at Iter.text (C:\Users\kunhy\node_modules\path-to-regexp\dist\index.js:128:30)

0|main | at consume (C:\Users\kunhy\node_modules\path-to-regexp\dist\index.js:152:29)

0|main | at parse (C:\Users\kunhy\node_modules\path-to-regexp\dist\index.js:183:20)

0|main | at C:\Users\kunhy\node_modules\path-to-regexp\dist\index.js:294:74

0|main | at Array.map (<anonymous>)

이렇게 오류가 나온다고 터미널에 뜨네요... 어떻게 해결해야할 지를 모르겠습니다


 

답변

답변을 기다리고 있는 질문이에요
첫번째 답변을 남겨보세요!
박건형님의 프로필 이미지
박건형

작성한 질문수

질문하기