I have a route like this to fetch a post with the associated comment.
Route::get('/api/topics/{category_id}/{title}', function($category_id, $title){
return App\Topic::with('comments')->where(compact('category_id','title'))->firstOrFail();
});
The thing is how can I pass a parameter variables to Vue.js?In this case "category_id" and "title",so Vue can fetch the post as well as the comments.
Below is my Vue instance which gives me this error:
main.js:11749Uncaught ReferenceError: category_id is not defined
Vue instance
new Vue({
el: '#comment',
methods: {
fetchComment: function (category_id, title) {
this.$http.get('/api/topics/' + category_id + '/' + title ,function (data) {
this.$set('topics',data)
})
}
},
ready: function () {
this.fetchComment(category_id, title)
}
});
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire