[Vuejs]-How to run ajax process first before calling slider on vue component?

0👍

mapActions maps your actions to store.dispatch, which returns a promise. You should be able to simply wait for the promise to resolve and then do your callback:

export default {
    ...
    props: ['leagueId'],
    created() {
        this.getTopLeague([{league_id: this.leagueId}])
            .then(function(){  
                $('.slick').not('.slick-initialized').slick({slidesToShow: 3, infinite: false});
            })
    },
    ...

0👍

I would suggest using an Ajax framework like Axios, or Vue-Resource and then wait for the server to respond before triggering your code.

axios.get(url)
.then( res => {
  //your code.
})

Leave a comment