For example, when i try console.log(this.products)
, the console returns a empty array. But the products was populate with a fetch on the created lifecycle. Or when i try to assign value to the variable items.
created() {
fetch("https://cardapio-digital-api.herokuapp.com/api/v1/products")
.then(response => {
return response.json()
})
.then(data => {
this.products = data
this.productsByCategory = this.products
})
console.log(this.products)
this.items = JSON.parse(localStorage.getItem('items'))
}