need help making get resource work using ESPAsyncWebServer
Posted: Sun May 24, 2020 5:19 pm
I am noob trying to use ESPAsyncWebServer.h,
in a serving a rest api that returns wifi hotspots.
But when in the setup function I try to setup server resource like this:
I am getting this error
in a serving a rest api that returns wifi hotspots.
Code: Select all
String* getWifiHotspots() {
// String* arr = new String[];
String arr[100];
Serial.print("Scan start ... ");
int n = WiFi.scanNetworks();
for (int i = 0; i < n; i++)
{
arr[i] = WiFi.SSID(i).c_str();
}
return arr;
}
But when in the setup function I try to setup server resource like this:
Code: Select all
ap_server.on("/hotspots",HTTP_GET, [](AsyncWebServerRequest * request) {
request->send_P(200, "text/plain", getWifiHotspots);
});
I am getting this error
Code: Select all
/libraries/ESPAsyncWebServer/src/ESPAsyncWebServer.h:244:10: note: void AsyncWebServerRequest::send_P(int, const String&, const char*, AwsTemplateProcessor)
void send_P(int code, const String& contentType, PGM_P content, AwsTemplateProcessor callback=nullptr);
^