I have a small api made in Laravel, it is working without problems and all the tests in Postman are successful, the problem is when I try to show the data by the Vue view, it just doesn't show me anything, not even errors
This is the view code
<template>
<div id="home" class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card card-default" v-for="product in products"
:key="product.id">
<div class="card-header">{{product.name}}</div>
<div class="card-body">
{{product.totalPrice}}
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
products: [],
}
},
created(){
this.allProducts();
},
methods: {
allProducts(){
let self = this;
let urlAllProducts = '/api/products';
axios.get(urlAllProducts)
.then(response => {
self.products = response.data;
})
.catch(err => {
})
}
},
}
</script>
ProductController
public function index()
{
return ProductCollection::collection(Product::all());
}
Api.php file
Route::apiResource('/products', 'ProductController');
Route::group(['prefix' => 'products'], function(){
Route::apiResource('/{product}/reviews','ReviewController');
});
The view looks like this
I'm a couple of hours already messed with this problem.
Any ideas? I use Laravel 5.6, Vuejs 2