다양한 귀욤뽁짝 Fetch 들 💦

Durumi Gim·2021년 3월 23일
0
  • 찜리스트 들어가기위한 인증토큰 빽으로 헤더에 담아 넘기기

찜리스트 인증인가로 보여주기

componentDidMount() {
    fetch('http://10.58.0.59:8000/user/wishlist', {
      // method: 'GET',
      headers: {
        Authorization:sessionStorage.getItem("token")
      },
    })
      .then(res => res.json())
      .then(res => {
      
        console.log('페치', res.result);
        this.setState({
          wishlistItems: res.result,
        });
      });

장바구니 텅텅 비우거라

 deleteAllHandler = () => {
    fetch(`${API}/cart`, {
      method: "DELETE",
      headers: {
        Authorization: localStorage.getItem("token"),
      },
    }).then((res) => {
      this.setState({ carts: [] });
    });
  };
      

profile
마음도 몸도 튼튼한 개발자

0개의 댓글