react - axios object

ash3767·2020년 6월 29일
0

react

목록 보기
14/41
post-thumbnail

backend

I wanted to send dictionary data to the frontend

 columns_list = [
        {"name" : now_day,"value":len(now_list)},
        {"name" : previous_day_one , "value" : len(previous_day_one_list)},
        {"name" : previous_day_two , "value" : len(previous_day_two_list)}]

     return JsonResponse({"data": {
 	.....
 
         "columns_list"   : columns_list,
            }}, status=200)

front

 const [column, setColumn] = useState(null);

  useEffect(() => {
    request
      .get("/excel/statistics")
      .then((res) => {
        let {
          data: { data },
        } = res;
       
        console.log(data.columns_list);
      })
      .catch((err) => {
        err && console.log(err);
      });
  });

but,,,infinite loop
i don't know why this code happen infinite loop

so.. just i try console.log

very great

ummmm.... why you don't ???
i did search

useEffect({},[]);

  useEffect(() => {
    request
      .get("/excel/statistics")
      .then((res) => {
        let {
          data: { data },
        } = res;
	....
        console.log(data.columns_list);
        setColumn(data.columns_list);
      })
      .catch((err) => {
        err && console.log(err);
      });
  }, []);

Wow :)

profile
꾸준함이란 ... ?

0개의 댓글