Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

122
Views
Vue (2.6.14) - v-for not displaying data with an api import (axios)

The idea I'm trying to build a display where activities are shown with some filters. The data comes from an API generated by the CMS. The filters are not shown in the code since its not relevant.

Problem When manually defining the 'items' in the data property the v-for list rendering displays fine and gives the desired output. When pulling the data from the api and assigning them to items the v-for is not displaying anything.

My Thoughts I think that the v-for is run before the api request is finished putting the data into the 'items' value. Currently I'm using 'created' property to fire the function, also used 'Mounted()' before, this also didn't work.

Versions Vue 2.6.14, Axios 0.21.1

Vue Code

var vue = new Vue({
    el: '#app',
    data: {
        items: null,
    },
    created: function () {
        this.fetchData()
    },
    methods: {
        fetchData: function() {
        axios
            .get('/api/activities.json')
            .then(response => (this.items = response.data.data))
        }
    }
})

Templating

<div id="app">
    <ul class="example">
        <li v-for="item in items">
            {{ item }}
        </li>
    </ul>
</div>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Your code seems to be working just fine. Look below, I just replaced your api call with a dummy REST api call and it's working just fine. Please console out the data from response.data.data and see if you are really receiving an array there.

Vue.config.productionTip = false
Vue.config.devtools = false


let vue = new Vue({
    el: '#app',
    data: {
        items: null,
    },
    created() {
        this.fetchData()
    },
    methods: {
        fetchData: function() {
        axios.get('https://jsonplaceholder.typicode.com/users')
        .then(response => {  this.items = response.data })}
    }
})
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>

<div id="app">
  <div id="app">
    <ul class="example">
      <li v-for="item in items">
        {{ item.id }} - {{ item.name }}
      </li>
    </ul>
  </div>
</div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!