我想从api提取数据以列出最喜欢的产品,我使用带有标头和正文的Post请求,但尝试了一些vue js和axios代码,但无法正常工作。以下是邮递员中的Api响应
https://anotepad.com/notes/gr6w67
以下是我的前端代码
<script>
new Vue({
el: '#app',
data () {
return {
info: null,
results:''
}
},
mounted () {
axios({
method: 'post',
url: url+'api/getallproducts',
data: {
language_id:1,
type:'most liked1',
page_number:1,
},
headers: {
"consumer-key": consumer_key,
"consumer-secret": consumer_secret,
"consumer-nonce": 2223344,
"consumer-device-id": consumer_device_id,
},
.then(response => {console.log(response.product_data.product_id)
//.then(response => {console.log(data)
//alert(response);
});
}
})
})
</script>
<div id="app" class="ltabs-items-inner ltabs-slider">
<template v-for="result in results">
<div class="row">
<div class="ltabs-item">
<div class="col-md-12">
<div class="item-inner product-layout transition product-grid">
<div class="product-item-container">
<div class="left-block">
<div class="product-image-container second_img"> <a href="#!" target="_self" title="Pastrami bacon"> <img src="{{ asset('public/frontend/qshopee')}}/image/catalog/demo/product/320/9.jpg" class="img-1 img-responsive" alt="Pastrami bacon"> <img src="{{ asset('public/frontend/qshopee')}}/image/catalog/demo/product/320/9.jpg" class="img-2 img-responsive" alt="Pastrami bacon"> </a> </div>
<div class="button-group so-quickview cartinfo--left">
<button type="button" class="addToCart btn-button" title="Add to cart" onClick="cart.add('60 ');"> <i class="fa fa-shopping-basket"></i> <span>Add to cart </span> </button>
<button type="button" class="wishlist btn-button" title="Add to Wish List" onClick="wishlist.add('60');"><i class="fa fa-heart"></i><span>Add to Wish List</span> </button>
<button type="button" class="compare btn-button" title="Compare this Product " onClick="compare.add('60');"><i class="fa fa-refresh"></i><span>Compare this Product</span> </button>
<!--quickview-->
<a class="iframe-link btn-button quickview quickview_handler visible-lg" href="quickview.html" title="Quick view" data-fancybox-type="iframe"><i class="fa fa-eye"></i><span>Quick view</span></a>
<!--end quickview-->
</div>
</div>
<div class="right-block">
<div class="caption">
<div class="rating"> <span class="fa fa-stack"><i class="fa fa-star fa-stack-2x"></i></span> <span class="fa fa-stack"><i class="fa fa-star fa-stack-2x"></i></span> <span class="fa fa-stack"><i class="fa fa-star fa-stack-2x"></i></span> <span class="fa fa-stack"><i class="fa fa-star fa-stack-2x"></i></span> <span class="fa fa-stack"><i class="fa fa-star-o fa-stack-2x"></i></span> </div>
<h4><a href="#!" title="Pastrami bacon" target="_self">Product Name</a></h4>
<div class="price"> <span class="price-new">$1000</span>
<span class="price-old">$1500 </span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
</div>
以下是Api邮递员的回复:https://anotepad.com/notes/gr6w67