/*
ESP32 HTTPClient Example
https://wokwi.com/arduino/projects/324787238284034642
*/
#include <WiFi.h>
#include <HTTPClient.h>
const char *ssid = "Wokwi-GUEST";
const char *password = "";
const String url = "https://serena-backend-2g6tjw7nja-et.a.run.app/serenplace";
void setup()
{
Serial.begin(115200);
WiFi.begin(ssid, password, 6);
Serial.print("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED)
{
delay(100);
Serial.print(".");
}
Serial.print("OK! IP=");
Serial.println(WiFi.localIP());
}
void loop()
{
delay(1000);
Serial.print("Fetching " + url + "... ");
HTTPClient http;
http.begin(url);
int httpResponseCode = http.GET();
if (httpResponseCode > 0)
{
Serial.print("HTTP ");
Serial.println(httpResponseCode);
String payload = http.getString();
Serial.println();
Serial.println(payload);
}
else
{
Serial.print("Error code: ");
Serial.println(httpResponseCode);
Serial.println(":-(");
}
}