Interval to Vue + Fetch Consume API StarWars

by WILLIAM CORREA

HTML

<div id="app">
  <div v-for="_person in people">
    {{ _person.name }}
  </div>
</div>

JavaScript

new Vue({
  el: '#app',
  data: () => ({
    people: [],
    counter: 0
  }),
  methods: {
  	request () {
    	this.counter++
    	this.people = []
    	fetch('https://swapi.co/api/people/')
        .then(response => {
          return response.json().then((data) => {
            this.people = data.results
          })
        })
        .catch(error => {
          alert(error)
        })
    }
  },
  mounted() {
    this.interval = window.setInterval(this.request, 30000)
  }
})