[TIL] 5th day of 'Food_Recipe' react project

Chaewon Yoon (Jamie)·2022년 8월 31일
0

inovation camp for frontend

목록 보기
21/30

9AM) 오전 회의
Form에서 서버로 데이터 저장하고
List는 서버에서 데이터 받아오는 걸 어제 했고
오늘은 상세페이지와 댓글에서도 서버에서 받아오는 거 하기
그리고 데이터 삭제, 수정 기능 구현

중간회고1) 3:20pm
댓글 서버에 저장되는 거 완료

//trouble shooting 
const data = await axios.get("http://localhost:3001/comments"); 
//http: 뒤에 슬래시// 필요!!!(학습자료에 잘못 나와 있음)
const onSubmitHandler = (event) => {
    event.preventDefault();
    dispatch(createComment({ ...comment, id: number }));
    axios.post("http://localhost:3001/comments", { ...comment, id: number });
    setComment(initialState);
    number++;
  };

//axios.post("http://localhost:3001/comments", { ...comment, id: number });
//이 부분을 빼먹어서 에러 났었는데 해결.

중간회고2) 4pm
댓글 삭제 구현 완료

const onClickDeleteButtonHandler = (commentId) => {
    axios.delete(`http://localhost:3001/comments/${commentId}`);
  };
//삭제 버튼
<button
  type="button"
  onClick={() => onClickDeleteButtonHandler(comment.id)}
  >
  삭제하기
</button>

중간회고3) 8pm
ㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠ
댓글창 다 망가졌다
ㅠㅠㅠㅠㅠㅠㅠㅠㅠ
뭐가 문제지
ㅠㅠㅠㅠㅠㅠㅠ
소연님이 살려주셨다

profile
keep growing as a web developer!🧃

0개의 댓글