
db에 저장 되어있는 데이터를 버튼 클릭 시 삭제하는 기능을 구현하고 있습니다.
삭제는 잘 되나, 제가 원하는 데이터를 클릭 했을 때 삭제되지 않고 다른 게 삭제가 되고 있습니다.
console.log()로 찍어보면 undefined로 데이터가 확인되지 않습니다.
우선, post로 데이터를 저장할 때 자동으로 생성되는 _id 값을 가져와 해당 _id 값을 지워주고 싶습니다!
@app.route('/get_posts/delete', methods=['POST'])
def delete_post():
id_receive = request.form.get('id_give')
print(type(id_receive))
db.posts.delete_one({'id': id_receive})
return jsonify({'msg': '삭제 완료'})
function delete_post(id) {
console.log(id)
$.ajax({
type: "POST",
url: `/get_posts/delete`,
data: {id_give: id},
success: function (response) {
alert(response["msg"])
window.location.reload()
}
});
}
이런식으로 구현했는데, 이미 존재하는 _id 값을 가져오려면 어떻게 코드를 작성해야 할까요?

