我正在编写一个服务器应用程序,并希望客户端使用body中的数据来参数化我的GET方法,就像这样:
# http -v GET http://localhost:3000/url text=123 foo=bar
GET /url HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate, compress
Content-Length: 29
Content-Type: application/json; charset=utf-8
Host: localhost:3000
User-Agent: HTTPie/0.4.0
{
"foo": "bar",
"text": "123"
}
在AngularJS中我尝试过:
var params = {
"foo": "bar",
"text": "123"
}
// no body
$http({
method: 'GET',
url: '/url',
data: params })
// ugly url
// also has its limitation: https://dev59.com/53NA5IYBdhLWcg3wZ85S
$http({
method: 'GET',
url: '/url',
params: params })
// params in body, but I wanted GET
$http({
method: 'POST',
url: '/url',
data: params })
这是设计还是一个bug?
从文档中我看不出原因。