250x250
반응형
Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Archives
Today
Total
관리 메뉴

BEAT A SHOTGUN

[TROUBLESHOOTING] AXIOS 400 ERROR - Required request parameter 'user' for method parameter type Long is not present 본문

TROUBLESHOOTING

[TROUBLESHOOTING] AXIOS 400 ERROR - Required request parameter 'user' for method parameter type Long is not present

thovy 2022. 9. 7. 10:49
728x90
반응형
SMALL

ERROR ❌

// FE
function replySubmit(){
  axios.get('http://localhost:8080/reply', {
    params:{
      userId:8,
      postId:1,
      contents:replyContent
    }
  })
    .catch(function(error){

    ...
// BE
@GetMapping("/reply")
public ReplyDTO writeReply(
        @RequestParam(value = "user") Long userId,
        @RequestParam(value = "post") Long postId,
        @RequestParam(value = "contents") String contents){
    return replyService.writeReply(userId,postId, contents);
}

GET 메서드를 이용해 댓글 기능을 만들려고 했다.

userIdpostId 를 임의로 넣어놓고 통신이 되는지 넣어봤는데,

)

허에에엥??????

userIduserId 를 넣는데 왜 user 가 없다하지????

해결 ✅

// FE
function replySubmit(){
  axios.get('http://localhost:8080/reply', {
    params:{
      user:8,
      post:1,
      contents:replyContent
    }
  })
    .catch(function(error){

    ...

FE 에서 userIduser 로 바꾸고, postIdpost로 바꾸면 된다.

BE 에서 userpostvalue 를 설정해놓고 저따위로 보내니 될리가..

친절한 에러메세지를 보면서도 깨닫지 못한 나, 반성해!

생각해보면 댓글 가져오기를 userId 로 가져오고 있으니. 내가 저렇게 보낸 것도 이해가 되기도 한다. 하지만 댕청했다는 건 변하지 않아.

끝!

항상 댕청해지지 않도록 조심하자!

728x90
반응형
LIST
Comments