V
V
Vanya Huk2017-07-03 15:46:26
JavaScript
Vanya Huk, 2017-07-03 15:46:26

Why does the VUE.js component not see properties?

Why doesn't the component see the product properties?

Vue.component('catalog-content-wrap', {
    template: '#catalog-content-wrap',

    data : function () {
        return{
                        products    : [],

                        filters     : [],

                        message     : 'hello'
                        }
    },

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

    methods : {

        get_catalog_content : function () {

            this.loader = true;

            this.$http.post( Website.href ).then(response => {
                this.products = response.body.products;
                console.log( response.body.products )
            } );

        }
    }
})

<script type="text/x-template" id="catalog-content-wrap">
        <div class="row no-margin catalog-content-wrap" id="catalog-content-wrap" >

            <div class="col-md-4 col-sm-4 col-xs-6 mob-product" v-for="product in products">
                {{product}}
</div>
</div>
             
    </script>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Kazakov, 2017-07-05
@walovari

this.$http.post( Website.href ).then(response => {
                this.products = response.body.products;
                console.log( response.body.products )
            } );

Is the request going to the correct url ? (What's in website.href ?)
this.$http.post( Website.href ).then(response => {
                this.products = response.body.products;
                console.log( response.body.products )
            },response => {
                console.error(response)
            }
 );

add a second function to handle the error case

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question