maakbaas / esp8266-iot-framework

Framework for IoT projects implementing HTTPS requests, a React web interface, WiFi manager, live dashboard, configuration manager, file manager and OTA updates.
GNU General Public License v3.0
416 stars 113 forks source link

fetch.read() to String #78

Closed Eisbaeeer closed 3 years ago

Eisbaeeer commented 3 years ago

Hi. Your example show´s how to get your fetch to a serial.write output. Is there an example to get the response to a string value or are you able to give me a hint to get the Serial.write to String? My target is to serialize.json the response of a https get. I don´t get the String from Serial.write(fetch.read()); to a string variable.

` Serial.println(ESP.getFreeHeap());

    fetch.GET("https://www.google.com");

    while (fetch.busy())
    {
        if (fetch.available())
        {
            Serial.write(fetch.read());           
        }
    }

    fetch.clean();`
Eisbaeeer commented 3 years ago

String line = fetch.readString(); Serial.println(line); done the job.