[Vuejs]-How to pass post parameter from laravel route to axios in vue js?

2๐Ÿ‘

โœ…

Your axios code is

axios.post('/payments', {
    
    params: {

        data_from: this.data_from,
        data_to: this.data_to

    }
})

if you dd($request->all()) in controller you will get below output

array:1 [
  "params" => array:2 [
    "data_from" => ""
    "data_to" => ""
  ]
]

so to fetch individual like below

$request->params['data_from']

So better pass data in axios like below

axios.post('/payments', {

        data_from: this.data_from,
        data_to: this.data_to
})

so you can fetch

$request->data_from

Ref: https://github.com/axios/axios

๐Ÿ‘คJohn Lobo

1๐Ÿ‘

Change that

            $data_from = $request -> $data_from;
            $data_to = $request -> $data_to;

for this

            $data_from = $request->data_from;
            $data_to = $request->data_to;
๐Ÿ‘คXRaspall

0๐Ÿ‘

try accessing route parameters like this $data_from = $request->data_from;

๐Ÿ‘คbrizzy_p

Leave a comment