skip to Main Content

I can’t get my v-loop to show the data in my object array. That i got from the API. It’s pretty simple, and im sure it should be working. So im wondering if it’s something else. The API is not open, so here is an image: https://imgur.com/a/qIES7Pm

<div class="" id="buffetfeatured">
    <div v-for="x in product">{{ x.title }}</div>
</div>

<script type="text/javascript">
    new Vue({
        el: '#buffetfeatured',
        data() {
            return {
                product: []
            }
        },
        mounted () {
            axios.get('https://ebuffet-dk.myshopify.com/admin/api/2020-01/products.json')
                .then(response => (this.product = response.data.products))
                .catch( error => { console.log(error); });
        }
    });
</script>

I know that there are similar examples, and i’ve tried following them. So im only asking, because im unsure if it’s my own fault, or shopify’s.

2

Answers


  1. Chosen as BEST ANSWER

    Alright for anyone in the future. The problem is shopify is passing {{ }}. Which means that my code won't work.

    But here is a solution i stumbled across.

    Embed Vue component within Shopify store


  2. youre v-for it is true but it doesn’t work because doesn’t have any data

    this code is wrong ** this.product = response.data.products**

    You cannot provide obj equal to arry you should push obj to array

    this.product.push(response.data.products)
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search