
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
데이터베이스에 저장은 되는데 그 후 fetch 함수 내에 것들이 작동하지 않고
TypeError: Object of type ObjectId is not JSON serializable 오류가 뜸
작성한 코드 및 에러 메세지
function save_comment() {
let formData = new FormData();
let name = $('#name').val()
let comment = $('#comment').val()
formData.append("name_give", name);
formData.append("comment_give", comment)
fetch('/guestbook', { method: "POST", body: formData, }).then((res) => res.json()).then((data) => { <----이 함수 내에 것들이 작동하지 않음.
alert(data)['msg']
window.location.reload() /
});
}
def guestbook_post():
name_receive = request.form['name_give']
comment_receive = request.form['comment_give']
doc={
'name': name_receive,
'comment': comment_receive
}
db.guestbook.insert_one(doc)
return jsonify({'msg': '저장 완료!', 'result': doc })
