13th Jun 2022, 11:39 PM
Simon Sauter
Simon Sauter - avatar
+ 2
data is a JSON object. Its contents are accessed using dot notation. So data.explanation accesses the data in the explanation field of the JSON object.
13th Jun 2022, 11:30 PM
Simon Sauter
Simon Sauter - avatar
+ 2
JSON is a format for saving data. It's very simple and very popular. You should take a look at it.
13th Jun 2022, 11:38 PM
Simon Sauter
Simon Sauter - avatar
+ 2
The call to the API fetches a JSON object. This is often the case for data APIs. This object is then assigned to the data variable for further manipulation. https://www.digitalocean.com/community/tutorials/how-to-work-with-json-in-javascript
14th Jun 2022, 12:20 AM
Simon Sauter
Simon Sauter - avatar
+ 1
In the code three fields of the JSON object are accessed: explanation, title, and url.
14th Jun 2022, 12:13 AM
Simon Sauter
Simon Sauter - avatar
+ 1
So the JSON object looks probably something like this: {"explanation": "some text", "title": "some text", "url": "an image url"}
14th Jun 2022, 12:16 AM
Simon Sauter
Simon Sauter - avatar
14th Jun 2022, 12:28 AM
Simon Sauter
Simon Sauter - avatar
0
That's lines 27-28. With the API's url in line 23.
14th Jun 2022, 12:33 AM
Simon Sauter
Simon Sauter - avatar
0
You're welcome.
14th Jun 2022, 12:34 AM
Simon Sauter
Simon Sauter - avatar
14th Jun 2022, 12:39 AM
Simon Sauter
Simon Sauter - avatar