Error with when trying to enter information with routes

Asked

Viewed 29 times

0

In api.php have that code:

Route::group(['middleware' => 'api'], function() {
   Route::post('clube/addClube', function(Request $request) {
       return App\clubes::addClube(['name' => $request -> input(['name'])]);
   });
});

In my file I have this method:

methods: {
    addLine(){
       this.list.push({clube: this.clube});
       this.$http.post('api/clube/addClube', this.clube);
    }
}

And in my Modal clubs.php:

namespace App;

use Illuminate\Database\Eloquent\Model;

class BD extends Model
{

}

And returns that error Uncaught TypeError: Cannot read property 'post' of undefined

  • I think you need to use vue-resource. npm install vue-resource --save. Em app.js: import VueResource from 'vue-resource'; and Vue.use(VueResource);. It seems that the $http function does not exist

  • Even installing and importing http://prntscr.com/g6e9kc, still error continues.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.