Hi, I'm a massive beginner with Arduino and I've been following this tutorial to send a GET request and displaying it on the serial monitor.
However upon even copy pasting the same code I get the following error:
getreq:29:15: error: call to 'HTTPClient::begin' declared with attribute error: obsolete API, use ::begin(WiFiClient, url)
29 | http.begin("http://jsonplaceholder.typicode.com/users/1"); //Specify request destination
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ exit status 1^
call to 'HTTPClient::begin' declared with attribute error: obsolete API, use ::begin(WiFiClient, url)
Any help would be appreciated.
This is the code if you don't want to follow the link, with SSID and pass removed ofc
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
const char* ssid = "yourNetworkName";
const char* password = "yourNetworkPassword";
void setup () {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print("Connecting..");
}
}
void loop() {
if (WiFi.status() == WL_CONNECTED) { //Check WiFi connection status
HTTPClient http; //Declare an object of class HTTPClient
http.begin("http://jsonplaceholder.typicode.com/users/1"); //Specify request destination
int httpCode = http.GET(); //Send the request
if (httpCode > 0) { //Check the returning code
String payload = http.getString(); //Get the request response payload
Serial.println(payload); //Print the response payload
}
http.end(); //Close connection
}
delay(30000); //Send a request every 30 seconds
}