[Vuejs]-Display an random Object from API Vue.js

0👍

you need to call this.choose() in your mounted/created hook after the promise is fulfilled if you want to make it appear on the page load as well. e.g:

mounted () {
  axios.get(url)
      .then(response => {
        this.artworks = response.data.names;
        this.choose()
      })
      .catch(e => {
        this.errors.push(e)
      })
}

Leave a comment