mizan_cs
1 month ago
285
5
Vue

Vue axios response data is not loading on component in Laravel

Posted 1 month ago by mizan_cs

I have made an axios request into a vue component from laravel project. Before axios finish request component is loading. and axios response data is not fetching on component.

<template>
    <div>
        <p>
            {{articles}}
        </p>
    </div>
</template>

<script>
    export default {
        name: "articles",
        components:{

        },
        data(){
            return {
                articles:[],
            }
        },

        methods:{
             fetchData() {
                 axios.get('https://jsonplaceholder.typicode.com/todos')
                    .then(response => (this.articles = response.data));
            },

        },
        mounted(){
            this.fetchData();
        },

    }
</script>

Please sign in or create an account to participate in this conversation.