I tried async function with await fetch and i am getting the result:
JS code:
async function getjson(){
await fetch('products.json')
.then((res) => res.json())
.then(function(data){
trick.push(data)
})
}
getjson();
const trick = [];
console.log(trick)
But how should i access all this data now and have it in variable?