'OpenWeatherMap API to get weather of multiple cities in XHR

I am new to API. I am trying to get the weather of 2 cities, but I am not able to think of a solution. Here is my code:

function loadDoc() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      myFunction(this);
    }
    //else alert("error");
  };
  xhttp.open("GET", "http://api.openweathermap.org/data/2.5/weather?q=Toronto&appid=1863e1cddf9f167c359054a40a64c6a7&units=imperial", true);
  xhttp.send();
}

I want to get the weather for New york as well in the "q=Toronto" part. Can someone help



Solution 1:[1]

To get weather of multiple cities, you need another API call.

xhttp.open("GET", "http://api.openweathermap.org/data/2.5/group?id=524901,703448,2643743&units;=metric&appid={API_KEY}", true);

For more details, it was answered here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dmytro Pavlov