how to send data to req.body while requesting through a HttpClient.get()
Asked
Active
Viewed 317 times
1
-
Manideep Mani: If you want to add additional information to your question then edit **your question**. If you want to comment on a particular answer then use the **comment** feature. I just rejected your edit to my answer because it wasn't answering your question. – Quentin Oct 20 '20 at 10:10
3 Answers
0
You don't.
The behaviour of a GET request with a body is undefined by the specification, and the APIs provided to client-side JS for making HTTP requests (fetch, XMLHttpRequest) do not support associating a request body with a GET request.
Quentin
- 857,932
- 118
- 1,152
- 1,264
0
As far as I can tell you cannot use HttpClient get to send a body. The only way is to use query.
const someObject = {example object};
http.get(url + '/?data='+ encodeURIComponent( JSON.stringify(someObject)));
Bozhinovski
- 2,192
- 2
- 22
- 29
-1
A get request can't have a body, you should use post or put https://www.w3schools.com/tags/ref_httpmethods.asp
keschra
- 167
- 1
- 13