안녕하세요.
아래는 제 코드입니다.
(server.js)
const methodOverride = require('method-override')
app.use(methodOverride('_method'))
app.put('/edit', function(요청, 응답){
db.collection('post').updateOne({ _id : parseInt(요청.body.id)},
{$set : {제목 : 요청.body.title, 날짜 : 요청.body.date}}, function(에러, 결과){
console.log('수정완료')
응답.redirect('/list')
})
})
(edit.ejs)
<div class="container mt-3">
<form action="/edit?_method=PUT" method="POST">
<div class="form-group">
<label >할일</label>
<input type="text" value="<%= post._id %>" name="id" style="display: none;">
<input value="<%= post.제목 %>" type="text" name="title" class="form-control">
</div>
<div class="form-group">
<label>due date</label>
<input value="<%= post.날짜 %>" type="text" name="date" class="form-control" >
</div>
<button type="submit" class="btn btn-danger">Submit</button>
</form>
</div>
edit페이지에서 Submit버튼을 누르면 "Cannot PUT /edit"이라는 에러가 뜹니다.
method-override라이브러리 설치하고 상단에 코드도 입력했는데 왜 put요청이
되지 않는지 이해가 되지 않습니다... 도와주세요..ㅠㅠ