Day 3, Exercise 1
Reflections
- A promise is a JavaScript object that represents/stores the eventual completion or failure of an asynchronous operation.
- fetch() returns promises
- Fetch is asynchronous, so the first callback is to handle the initial response from the server and the second is to handle the actual data that doesn't show up at the exact same time
- In the first then() we check the response and do potential error handling if it's not ok, and control what form we get the data in (for example convert it to JSON or read it as text or however we want it)
- In the second then() we process the actual data - and it is only available here inside the callback so we need to somehow store it or do our DOM-manipulations based on it here and now.