0
我試圖將一組嵌套查詢參數傳遞給我的Laravel 5.1 API。我使用$httpParamSerializer(params)
序列化對象,這似乎這樣做是正確的GET
是這樣的:當我返回從Laravel的$request
Laravel解析嵌套的序列化查詢字符串
GET "http://my-api.localhost/1.0/categories?category=Anatomy&category=Consent+Forms"
然而,它只顯示屬性中的一種:
Object {category: "Consent Forms"}
這是爲什麼?
角前端:
var filters = {
category : ['Anatomy', 'Consent Forms']
};
Category.getCategories(filters).then(function(res) {
// Object {category: "Consent Forms"}
console.log('CATEGORIES', res.data);
角HTTP請求:
getCategories: function(params) {
var qs = $httpParamSerializer(params);
return $http({
method: 'GET',
url: url + ver + '/categories?' + qs,
headers: Auth.getOAuthHeader(),
cache: true
});
},
Laravel:
public function getCategories(Request $request) {
$input = $request->all();
return $input;