You need to assign the data to hubs.
Aug 31, 2018
28
Level 15
Problem loop json in v-for vue.js
I have the following witch is returning the correct data i can see it with console.log()
<script>
export default {
data() {
return {
hubs: []
}
},
methods: {
read() {
axios.get('/api/hub').then(({ data }) => {
console.log("Went though" + data)
})
.catch((err) => console.error(err));
},
},
mounted() {
console.log('Component mounted.')
}
}
</script>
in the same file component eg the script above
<template>
<ul>
<ul id="example-1">
<li v-for="hub in hubs">
{{ hub }}
{{ hubs }}
</li>
</ul>
</ul>
</template>
The html is there but no value.
Level 47
like i said before , you need to call the method in your mounted.
mounted () {
this.read()
}
just that line, no other code
Please or to participate in this conversation.