Bacancy Technology
Bacancy Technology represents the connected world, offering innovative and customer-centric information technology experiences, enabling Enterprises, Associates and the Society to Rise™.
12+
Countries where we have happy customers
1050+
Agile enabled employees
06
World wide offices
12+
Years of Experience
05
Agile Coaches
14
Certified Scrum Masters
1000+
Clients projects
1458
Happy customers
Artificial Intelligence
Machine Learning
Salesforce
Microsoft
SAP
September 28, 2023
Here’s an example, how you can send request data from axios to controller of laravel route.
axios.post('/payments', { params: { data_from: “test data from”, data_to: “test data to” } })
Route:
Route::post(‘/payments’, ‘Api\PaymentController@apiPaymentByUserId’);
Controller:
Class PaymentController extends Controller { public function apiPaymentByUserId(Request $request) { dd($request->all()); } }
We will get below output from dd($request->all());
Output:
array:1 [ "params" => array:2 [ "data_from" => "test data from" "data_to" => "test data to" ] ]
You also can access individual property of request using below code of Controller:
Class PaymentController extends Controller { public function apiPaymentByUserId(Request $request) { $data_from = $request->data_from; $data_to = $request->data_to; } }