#include <WiFi.h>
#include <HTTPClient.h>

// Replace with your web service URL
//const char* webServiceURL = "https://reqbin.com/echo";
const char* webServiceURL = "https://openweathermap.org";

void setup() {
  Serial.begin(9600);
  Serial.print("Connecting to WiFi");
  WiFi.begin("Wokwi-GUEST", "", 6);
  while (WiFi.status() != WL_CONNECTED) {
    delay(100);
    Serial.print(".");
  }
  Serial.println(" Connected!");
}

void loop() {
  delay(100); // TODO: Build something amazing!

  // Make HTTP request to web service
  HTTPClient http;
  http.begin(webServiceURL);
  int httpResponseCode = http.GET();
  //int httpResponseCode = http.POST("");
  if (httpResponseCode > 0) {
    Serial.print("HTTP response code: ");
    Serial.println(httpResponseCode);
    String payload = http.getString();
    Serial.println("Response payload: ");
    Serial.println(payload);
  } else {
    Serial.print("HTTP request failed with error code: ");
    Serial.println(httpResponseCode);
  }
  http.end();
  delay(5000);
}