0

i am doing a react project now and there is an api to fetch a list which is a GET request. In that request i have to pass parameters as formdata. Im using axios to make api calls. I tried the below code

   const formData = new FormData();
   formData.append("name", "john");

   return await API.get(
      "api/endpoint/getAllEmployees",
      formData
      // {
      //    headers: {
      //       "content-type": "multipart/form-data",
      //    },
      // }
   );

but when i look at the network tab,there is no formdata is sent with the request. Do anyone know how to send formdata in a get request using axios

anil kumar
  • 19
  • 6
  • axios({ method: "GET", url: yourURL, data: formData, header: { 'Content-Type': 'multipart/form-data' } }) – Not A Bot Nov 11 '20 at 13:16

1 Answers1

0

actually, you can't do it ,ref to rfc2616#,a get request can't carry a body with it, even you did it, the server will still ignore it.

Community
  • 1
  • 1
misaka
  • 43
  • 6