samedi 27 août 2016

Http callback is never called, Vue Laravel

Got this in a Vue component (Users.vue). The fetchUsers-function is called but the callback-function is NEVER called. I've tried to attach .error()-func but I get an error of this.$http.get(...).error is not a function.

<template>
    <div class="panel panel-default">
        <div class="panel-heading">Användare</div>

        <div class="panel-body">
            <table class="table">
                <thead>
                    <tr>
                        <th>#</th>
                        <th>Name</th>
                        <th>Email</th>
                    </tr>   
                </thead>
                <tbody>
                    <tr v-for="user in users">
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</template>

<script>
    export default {

        name: "Users",

        ready() {
            console.log('Component ready.')

            this.fetchUsers();
        },

        methods: {
            fetchUsers: function() {
                console.log("Fetching users...");

                this.$http.get('/api/user', (data) => {
                    this.$set("users", data);
                });
            }
        }
    }
</script>

I use Laravel's framework that ships with Vue.js. Don't know how it all works but I get the component showing up in the web browser and I get output in the console from this code.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2bYlmsZ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire