[Vuejs]-How to send data to routes use get method on the vue.js 2?

0👍

Try changing the line:

dd(Input::get('page'));

to:

return Input::get('page');

The dd method will dump a var value and halt the execution. So the output won’t be a properly formatted json. It will probably be some raw html displaing the value you dumped.

0👍

This is full example of vue js code

var app = new Vue({
    el: '#invoice',
    data: {
        form: new FormData(),
        errors: {},
        tax: 0
    },
    methods: {
    random: function () {
      this.form.serial = Math.floor(Math.random() * 1000000) + 1;
    },
    sortBy: function() {
        if(this.form.tax_id) {
          var url = '{{route('invoice.get_tax', null)}}';
          this.$http.get(url)
           .then(function(response){
              if(response.data) {
                  console.log(response.data)
              }
           });
        }
     }
 })

There is the route

Route::get('/get_tax/{tax_id}', function($tax_id)
{
    $tax = App\Tax::findOrFail($tax_id);
    if ($tax) {
        return response()
            ->json([
                'rate' => $tax->rate,
                'type' => $tax->type
            ], 200);
    } else {
        return response()
            ->json([
                'rate' => 0,
                'type' => 1
            ], 200);
    }
})->name('invoice.get_tax');

Leave a comment