I'm trying to create a laravel app with a Vue.js to call a controller response, I've tried it with ajax alone and it works, but with Vue the GET method seems not working, there are also no error code for me to debug.
here is my Vue.js
<template>
<div>
<ul class="list-group list-group-flush">
<li class="list-group-item" v-for="unregboard in unregboards" :key="unregboard.boardId">
{{ unregboard.boardName }}
</li>
</ul>
</div>
</template>
<script>
export default {
data(){
return{
unregboards:[]
}
} , created: function(){
this.fetchUnreg()
}, methods:{
fetchUnreg: function () {
console.log("test"); //this works
this.$http.get('/registerlist', function(resp){
this.unregboards = resp.unRegBoards;
console.log(resp.unRegBoards);
console.log('test'); // This doesn't
}).bind(this);
}
}
}
</script>
<style>
</style>
UPDATE
I have fixed something and the code, I had my hopes up, because unlike before I was able to log my json response, check my code below:
<template>
<div>
<ul class="list-group list-group-flush">
<li class="list-group-item" v-for="unregboard in unregboards" :key="unregboard.boardId">
{{ unregboard["boardName"] }}
</li>
</ul>
</div>
</template>
<script>
export default {
data(){
return{
unregboards:[]
}
} , created: function(){
this.fetchUnreg()
}, methods:{
fetchUnreg: function () {
console.log("test");
$.get('/registerlist', function(resp){
this.unregboards = resp.unRegBoards;
console.log(resp.unRegBoards);
});
}
}
}
</script>
<style>
</style>
The problem is on the template, I does not return anything on the "unregboards" Vue.js's For loop
Additional Info this is the json file that's being returned:
{
"regBoards":[
{
"boardName":"Client 1",
"boardId":"594a0ec09ad35eba4434142r",
"organization":"Dream Inc."
},
{
"boardName":"Welcome Board",
"boardId":"58d311eeace6df3821107648",
"organization":null
}
],
"unRegBoards":[
{
"boardName":"Client 2",
"boardId":"5935fc808823fdbe2875d63g",
"organization":"Dream Inc."
},
{
"boardName":"Client 3",
"boardId":"59190bf0b27a6f308820rh5u",
"organization":"Dream Inc."
},
{
"boardName":"Client 4",
"boardId":"58a5006e9985e088628f634g",
"organization":"Dream Inc."
},
]
}