I need to pass those parameters data_from and data_to to the axios call but it's not working. I'm doing something wrong? The response is undefined.
Controller:
class PaymentController extends Controller
{
public function apiPaymentByUserId(Request $request) {
$data_from = $request -> data_from;
$data_to = $request -> data_to;
$payments = DB::table("casefiles, payments")
->select("payments.*")
->where("casefiles.id", "=", 'payments.casefile_id')
->where("casefiles.user_id", "=", Auth::id())
->where("payments.created_at", ">=", $data_from)
->where("payments.updated_at", "<=", $data_to)
->get();
return response()->json([
'success' => true,
'response' => $payments
]);
}
}
Route:
Route::post('/payments', 'Api\PaymentController@apiPaymentByUserId');
Axios call with vue js:
axios.post('/payments', {
params: {
data_from: this.data_from,
data_to: this.data_to
}
})