[Axios] delete 요청 시 body에 데이터 넣기

김승훈·2021년 5월 20일
0

React

목록 보기
9/14

axios를 이용하여 서버와 프론트에서 데이터를 주고 받는데 get이나 put을 이용하면 body로 request를 받아올수 있다 delete는 못받온다?? 왜일까 검색을 해보았지만 답을 찾지 못했지만 해결방안을 알았다. ㅠㅠ

delete 두 번째 인자에 data: {} atrribute를 이렇게 data:{data} 넣어주면 된다.

해결방법

Axios.delete(`/post/like`, {
    data: { 
      key1: ...
      ket2: ...
    },
  });

https://stackoverflow.com/questions/51069552/axios-delete-request-with-body-and-headers

0개의 댓글