Sending Request body for GET method in AXIOS throws error

后端 未结 3 758
暖寄归人
暖寄归人 2020-12-20 07:47

I have a React application where I am changing POST method to GET with the request body as it is. It works fine with POST request however when I change the method to GET, it

3条回答
  •  北海茫月
    2020-12-20 08:33

    This is not axios, the error origniates from the java backend you're talking to. The public field in your request body is missing.

    If you just want to send the data as parameters (which would be odd), pass it using params instead of data (as shown here: https://github.com/axios/axios#example).

    I personally don't think your API should support GET with a request body (talk to the devs and ask for documentation).

提交回复
热议问题