Internet data (JSON)
Advanced · Ask an API for a city's temperature and show it on the stage.
Interactive tutorial: the editor checks each step by itself.
- Add the "Web and JSON" extension.
- Choose a sprite and drag "when flag clicked".
- Snap "GET request to … named request1 and wait" below (the weather address is already filled in).
- Snap "say" (Looks) and put "value current.temperature_2m of JSON …" inside it.
- In that block's "JSON" slot, put "answer of request1".
- Click the flag. The first time, allow access to the site. What's the temperature?
- Challenge: use "when request request1 fails" to warn when there's no internet. (challenge)