ESP-01 read is empty

Okay, so this is a mystery to me: I have created a simple script for the ESP-01. The idea is that is sends a POST to an API. I connected the ESP-01 to Arduino UNO and at first it seemed to work. I also got some information back from the ESP-01 which helped me to see if there are any problems.

I first followed this tutorial: How to Program ESP8266 (ESP-01) Module with Arduino UNO - Arduino Project Hub

I flashed it. But the rest of the tutorial didn't seem to working for what I wanted to achieve. So, I went on searching on Google.
Then I found this website: http://domoticx.com/esp8266-wifi-webserver-via-een-arduino-at/. It is Dutch, but the code seemed to work.

Now, my problem is with this function:

String sendData(String command, const int timeout, boolean debug) {
String response = "";
esp8266.print(command); // Send a "read" character to the ESP
long int time = millis();
while( (time+timeout) > millis()) {
while(esp8266.available()) { // The ESP has data to show, show it on the serial monitor
char c = esp8266.read(); // Read the next character
response+=c;
}
}
if(debug) { Serial.print(response); }
return response;
}

At first, the Serial.print(response); showed the needed information in the SerialMonitor. But somehow it stopped doing that. It just prints empty lines. I have no idea why and how this happened.

What am I missing?

what value are you using for the timeout? It might take the esp8266 a bit of time to respond after receiving the command and if you don't wait long enough, it times out and returns nothing.

Also, that timeout is broken, millis() returns an unsigned long variable and will eventually roll over and break unless you do it like this

unsigned long int time = millis();
while ( (millis() - time)  < timeout)) {
  while (esp8266.available()) { // The ESP has data to show, show it on the serial monitor
    char c = esp8266.read(); // Read the next character
    response += c;
  }
}