如何使用HttpClient将内容发送到angular中GET请求的req.body?

How to use HttpClient to send content into req.body of GET request in angular?

如何在通过 HttpClient.get()

请求时将数据发送到 req.body

你不知道。

规范未定义behaviour of a GET request with a body,提供给client-sideJS的HTTP请求API(fetch,XMLHttpRequest)不支持关联带有 GET 请求的请求正文。

据我所知,您不能使用 HttpClient get 发送正文。唯一的方法是使用查询。

const someObject = {example object};
http.get(url + '/?data='+ encodeURIComponent( JSON.stringify(someObject)));

get 请求不能有正文,您应该使用 post 或输入 https://www.w3schools.com/tags/ref_httpmethods.asp