I must be getting tired but I can't figure this thing out. I have the following code:
fetch(url, options)
.then(function(response) {
return response.json();
})
.then(function(myJson) {
setTimeout(function(){
if (myJson == undefined)
{
console.log("fetch failed")
}
else
{
//inspect the data that the WebAPI returned
console.log("myJson: ", myJson);
}
}, 3000);
});
the variable url is populated with an API url that returns the following string of data (I got this by entering the string that I use to fetch directly into a browser):
{"products":[{"barcode_number":"5000159459228","barcode_type":"EAN","barcode_formats":"EAN 5000159459228","mpn":"","model":"","asin":"B01K4FU9K6","product_name":"Twix (50g x 6)","title":"","category":"Toys & Games > Toys > Pretend Play > Pretend Shopping & Grocery","manufacturer":"Mars","brand":"","label":"Mars","author":"","publisher":"Mars","artist":"","actor":"","director":"","studio":"","genre":"","audience_rating":"","ingredients":"","nutrition_facts":"","color":"","format":"","package_quantity":"","size":"","length":"","width":"","height":"","weight":"","release_date":"","description":"Milk chocolate covered caramel and biscuit.","features":[],"images":["https://images.barcodelookup.com/4488/44880860-1.jpg"],"stores":[{"store_name":"Rakuten Deutschland GmbH","store_price":"23.57","product_url":"https://www.rakuten.de/produkt/twix-32-riegel-grosspack-2179063860","currency_code":"EUR","currency_symbol":"€"}],"reviews":[]}]}
When I look at the console to see the log, this is what I see:
For some reason, I can not figure out how to reference a specific element in the myJson object.
How would I reference the barcode_formats field?
Thank you.