Fetch API (JavaScript)
I'm attempting to call a URL and return data. Running the original console log (response) without the data line returns the promise result object of product. However, when I call data.title, I'm expecting it to return ("SAN FRANCISCO GIANTS 2000 INAUGURAL SEASON"), but it's not able to read these properties as title is undefined?
5 Replies
I've also tried:
console.log(data.product.title)
and console.log(data[0].title)
you are returning a console log, not the response.json() itself
and yes, the title is in product
I closed the other post, I apologize didn't see this
Just out of curiosity, why does json() function need to be called despite url returning json?
.json() converts it to a native JavaScript object
okay cool makes sense