Answer the question
In order to leave comments, you need to log in
Vue js How to validate by user id and display exactly his product?
I want to display the user's purchase history and product in my account.
I take the ID from the address bar, example: domain.ru/profile/1
I tried it this way:
async beforeRouteProducts (to, from, next) { try {
const { data } = await axios.get(`/api/v1/companies/${this.$route.params.id}`)
next(vm => { vm.products = data })
} catch (e) {
next(vm => { vm.error = e.response.data })
} },
<div class="card-carousel--card" v-for="product, index in products">
<router-link :to="{ name: 'product', params:{id:product.id}}">
<img :src="product.img_index"/>
<div class="card-carousel--card--footer">
<p>{{ product.name }}</p>
<p class="tag" v-for="(tag,index) in product.price" :class="index > 0 ? 'secondary' : ''">{{ tag }}</p>
</div></router-link>
</div>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question