I'm using Laravel 5.3, and I'm having trouble submitting arrays of objects to my controller. Is it possible? And if not, is there a workaround so that I can submit multiple objects at once?
Example request:
let req = {
'data[]': [
{ id: 1, name: 'test1' },
{ id: 2, name: 'test2' }
]
};
Then, to test, I simply returned the contents of the request:
public function testArray(Request $request) {
return response()->json($request->all());
}
And got this result:
data: [
"[object Object]",
"[object Object]"
]
Content-type: application/json?json). Additionally, you can also add another one telling the format that you expect:Accept: application/json