ESP8266 Read a .txt or .php file

Hey guys, i have been struggling to find anything on the web for this problem. So far no luck.
On a raspberry Pi (hosting a server) i am storing some files. I would like to access those files using ESP8266 module.

When i go to the local adress “http://192.168.2.101/TEST/data.php” on my computers web browser, there is data displayed (just one number).

i cannot seem to go to that site with the ESP and read what it says. I have read a bunch of things and actually do not know how to fetch that data without GET requests. All i want is just to read that single number that is displayed when you go to that site.

tomig:
I have read a bunch of things and actually do not know how to fetch that data without GET requests.

Then use a GET request, just like your browser does.

String url = "https://192.168.2.101/test/test.php";

http.begin(url); xrpi = http.GET(); http.end();

Serial.println("xrpi is:"); Serial.println(xrpi); Serial.println("\n"); delay(500);

in the xrpi String it only writes a 200 or a -1. What am i doing wrong?

tomig: in the xrpi String it only writes a 200 or a -1. What am i doing wrong?

http.GET() returns a status code AS AN INTEGER, NOT A STRING. -1 means ERROR. 200 is HTTP_CODE_OK, the code for "OK" so in those cases, you fetch the response with "String payload = http.getString();".