- From: Clifford Fajardo <notifications@github.com>
- Date: Sat, 27 Aug 2022 15:00:19 -0700
- To: whatwg/fetch <fetch@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Saturday, 27 August 2022 22:00:32 UTC
I tried using `fetch` and `node-fetch` to make GET with a request body, but it fails with: ``` Request with GET/HEAD method cannot have body ``` ### Workaround for Nodejs runtimes (not in browser ... JS on the server) Wanted to share a solution for those who don't have control over the API but would to make GETs with request bodies in NodeJS . You can use the [axios library](https://www.npmjs.com/package/axios) to make GET with request body's ```js // only works in node / server -- i have not tried in the browser const res = await axios.get("/api/devices", { data: { deviceName: 'name' } }) ``` -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/fetch/issues/551#issuecomment-1229275789 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/fetch/issues/551/1229275789@github.com>
Received on Saturday, 27 August 2022 22:00:32 UTC