Making a request to an API consists of using a GET, PUT, POST, or DELETE method on a URL with some optional data. A well-designed API will be designed to have most of the information about the request in the URL. This means that we will be changing the URL based on the user choices.
For the Open Weather Maps API, the URLs that we need to send our requests to are structured as follows:
- For current weather: https://api.openweathermap.org/data/2.5/weather?q={$city},us
- For a five-day forecast: https://api.openweathermap.org/data/2.5/forecast?q=${city},us
Unfortunately, the API needs us to define a country code. In this example, we should use US, as we selected US_CITY as our slot type. If you chose a different slot type, ...