I want to pass in multiple parameters from my Angular app to my Laravel API, namely the id
and choices
array supplied by user.
Angular:
http request:
verifyAnswer: function(params) {
return $http({
method: 'GET',
url: 'http://localhost:8888/api/questions/check',
cache: true,
params: {
id: params.question_id,
choices: params.answer_choices
}
});
Laravel 5:
routes.php:
$router->get('/api/questions/check/(:any)', 'ApiController@getAnswer');
ApiController.php:
public function getAnswer(Request $request) {
die(print_r($request));
}
I thought I should use :any
within my URI to indicate I'll be passing in an arbitrary amount of parameters of various data structure (id is a number, choices is an array of choices).
How can I make this request?
[200]: /api/questions/check?choices= choice+1 &choices= choice+2 &choices= choice+3 &id=1