
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
function show_comment() {
fetch('/',{ method: "GET" }).then((res) => res.json()).then((data) => {
let rows = data['result']
console.log(rows)
})
}
제 다른 팀원이 이렇게 썼었는데
강의에서 선생님은 {method: "GET"} 이걸 안넣고서도 쓰시더라구요.
제가 지금 포스트는 했는데
겟은 콘솔에
Uncaught (in promise) SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
이 에러가 떠서 이것저것 시도해보고 있는 와중에 저걸 발견해서 궁금했어요.
$(document).ready(function () {
show_comment();
});
function save_comment() {
let name = $('#name').val()
let comment = $('#comment').val()
let formData = new FormData();
formData.append("name_give", name);
formData.append("comment_give", comment);
fetch('/', {method: "POST", body: formData,}).then((res) => res.json()).then((data) => {
alert(data["msg"]);
});
}
function show_comment() {
fetch('/',{ method: "GET" }).then((res) => res.json()).then((data) => {
let rows = data['result']
console.log(rows)
})
}
페치 전체 코드는 이렇게 되는데 뭐가 문젤까용
