Open ImParks opened 1 month ago
API 폴더 정리 완
@Autowired 누락으로 인한 버그 발생. 앞으론 꼭 넣기
axios 인코딩 버그 발생
axios 로 channelId 의 값을 서버로 전달할때 channelId + "=" 가 된 값으로 전달됨,
버그 원인
axios 가 post 전송을 할때 데이터 인코딩을 application/x-www-form-urlencoded 방식으로 진행하는대 이를 axios 가 자동으로 URL 인코딩을 하려고 시도하면서 끝에
=
가 붙어 발생한 버그
버그 해결
기존의 코드에서 조금 변경하여 const { data } = await axios.post(
/channel/check
, channelId, { headers: { 'Content-Type': 'text/plain' } }); headers 에 데이터가 단순 text 라고 해주면 해결됨.
위 인코딩 버그가 발생하며 명확하게 알아낸것 @RequestBody 는 Dto 전용 , Post 전용 ex) @RequestBody ChannelIdDto channelId 가져오는 데이터가 1개여도 Dto 로 받아와야함
@RequestParam 는 파라미터로 가져오는 정보 전용, Get 전용 ex)@RequestParam("channelId") String channelId