IT'S DO
728x90
function findBoard() {

    const id = /*[[ ${id} ]]*/;

    fetch(`/api/events/${id}`).then(response => {
        console.log('response',response); // json 데이터 파싱
        if (!response.ok) {
            throw new Error('Request failed...');
        }
        return response.json();

    }).then(json => {
        console.table(json); // json 데이터 가져옴.
        json.createdDate = moment(json.createdDate).format('YYYY-MM-DD HH:mm:ss');
        console.log(Object.keys(json),'Object.keys(json)'); // json 데이터를 key로 만듬.
        console.log('document.getElementById(title)',document.getElementById('title'));
        Object.keys(json).forEach(key => { // 해당 키를 document.getelementById 각각의 id html 태그에 넣어라 라는뜻
            const elem = document.getElementById(key);
            console.log('elem',elem);
            if (elem) {
                elem.innerText = json[key];
                console.log('json[key',json[key]);
            }
        });

    }).catch(error => {
        alert('게시글 정보를 찾을 수 없습니다.');
        goList();
    });
}
profile

IT'S DO

@멋진놈

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!