aimeos and vuejs ( axios.get )

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
mahmoud
Posts: 27
Joined: 27 Mar 2020, 22:01

aimeos and vuejs ( axios.get )

Post by mahmoud » 02 Jul 2020, 20:05

Hello,
I use laravel and vuejs I want to display the product attributes using the following function:

Code: Select all

<script>
    export default {
        data () {
            return {
                products: {}
                    }
                },
            created () {
                this.getProducts (); },
            methods: {
                getProducts () {
                   axios.get ('/ api / jsonapi / product')
                    .then (response => this.products = response.data)
                    .catch (err => console.log (err));
                }
            }
    }
</script>
and display the data in the component by the for ball like this:

Code: Select all

<tr v-for = "(product, index) in products.data"
                        : key = "index">
                        <th scope = "row"> {{index}} </th>
                        <td> {{product.id}} </td>
                       <td>  {{product.attributes.product.id. }}</td>
                        <td> </td>
                          <td> {{product ['attributes'] [product ['id']]}} </td>
                         </tr>
but the last two lines ( {{product.attributes.product.id. }} ... ) are not correct.

Thank you

mahmoud
Posts: 27
Joined: 27 Mar 2020, 22:01

Re: aimeos and vuejs ( axios.get )

Post by mahmoud » 03 Jul 2020, 00:55

Hello,
the secret line is :

Code: Select all

 {{ product.attributes["product.url"]}}
It works very well !!! , but now I want to display pagination but I don't know how, there is no page variable to do like this:

Code: Select all

</div>  <div class="card-footer d-flex justify-content-center">
                    <pagination :data="products" @pagination-change-page="getProducts"></pagination>

                    </div>
this for offset:

Code: Select all

 axios.get('/api/jsonapi/product?page[offset]=0')
Thank you

User avatar
aimeos
Administrator
Posts: 7892
Joined: 01 Jan 1970, 00:00

Re: aimeos and vuejs ( axios.get )

Post by aimeos » 03 Jul 2020, 11:34

The links section of the response contains the first, prev, next and last links which you can use to build the pagination.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply