I know a GET request shouldn't have a body, but unfortunately when writing the server I didn't know that, and I am not allowed to change it. The server(Node.js) expects the get request to contain a body with a parameter. When searching for the issue I have seen a few answers mention that it is possible but none said how. I have tried to send it this way with no success:
$http.get('http://localhost:3000/foo/bar',{
data: {'foo':bar},
headers: {'Content-Type': 'application/json;charset=utf-8'}
})
Thanks!
From the Docs:
The XMLHttpRequest method
send()
, sends the request to the server.If the request method is GET or HEAD, the body parameter is ignored and the request body is set to
null
.
Since the $http.get
method wraps the XHR.send() method, it can't send a body with its request.
For more information, see
你可以通过身体参数来获得这样的要求
$http.get('http://localhost:3000/foo/bar',{params: {'foo':bar}} })
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.