0

I am using apisauce in a react native app. How can I send body with GET method?

enter image description here

const getMissedLesson = async () => {

  const body = {
    termId: "10BEDDF3",
    inactivityMinute: 20
  };
  return await apiClientTicket.get('/v1/support/missedLessonList', null);
};
SoF
  • 729
  • 1
  • 10
  • 24
  • 3
    It is not recommended to use a body with GET requests and many libraries don't allow it https://stackoverflow.com/questions/978061/http-get-with-request-body – Tobias S. Apr 05 '22 at 11:25
  • Are you using `fetch`? – Dai Apr 05 '22 at 11:26
  • 1
    Definitely check out the article mentioned by Tobias. Basically, while GET isn't strictly forbidden from having a body, many libraries aren't written to allow it to have a body and may act weird. Looking at apisauce's documentation specifically, it seems they only allow a body on post, put, and patch. The second parameter of get is will always get turned into query strings instead. – samanime Apr 05 '22 at 11:34
  • On my attempts using GET body with fetch it didnt worked – Rooki Apr 05 '22 at 11:37
  • 1
    At the moment you need `body`, convert to a POST method, because it is not recommended to use GET with a body. You can use post with /:id too. – Muhamet Smaili Apr 05 '22 at 11:40
  • Okay i understood. Thanks for all answers! – SoF Apr 05 '22 at 11:44

0 Answers0