react 비동기 값 확인

김용희·2022년 2월 7일
0
const __GetFeedState = (token: string | null) => {
    return axios({
      method: "GET",
      url: "http://localhost:8080/feed",
      // url: "https://jsonplaceholder.typicode.com/comments",
      headers: { Authorization: "Bearer " + token },
    })
      .then((res) => {
        console.log(res);
        return res.data;
      })
      .catch((err) => {
        return err;
      });
  };

  useEffect(() => {
    const token = localStorage.getItem("Token");
    __GetFeedState(token);
  }, [__GetFeedState]);
  

 const __GetFeedState = (token: string | null) => {
    return axios({
      method: "GET",
      url: "http://localhost:8080/feed",
      // url: "https://jsonplaceholder.typicode.com/comments",
      headers: { Authorization: "Bearer " + token },
    })
      .then((res) => {
        // console.log(res.data.detailFeedDtos);
        let feeds = res.data.detailFeedDtos;
        // console.log(feeds);
        feeds.find((els: any) => {
          console.log(els.feed);
          let elss = els.feed;
          // elss.finds((elw: any) => {
          //   console.log(elw);
          // });
        }),
          feeds.map((elm: any) => {
            console.log(elm.feed);
            // eml = elm.feed;
            // return elm;
          });
        return feeds;
      })
      .catch((err) => {
        return err;
      });
  };
profile
He threw his knapsack over the brick wall

0개의 댓글