Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid conversion from 'const AsyncWebParameter*' to 'AsyncWebParameter*' #1434

Open
UnivespWagnerQueiroz opened this issue Sep 24, 2024 · 1 comment

Comments

@UnivespWagnerQueiroz
Copy link

I try to get the list of parameters with the example below, however I get the error below:

Compilation error: invalid conversion from 'const AsyncWebParameter*' to 'AsyncWebParameter*' [-fpermissive]

Someone can help me with this? I'm using Arduino 2.3.2 on Windows and Linux.

#include "WiFi.h"
#include "ESPAsyncWebServer.h"
 
const char* ssid = "yourNetworkName";
const char* password =  "yourNetworkPass";
 
AsyncWebServer server(80);
 
void setup(){
  Serial.begin(115200);
 
  WiFi.begin(ssid, password);
 
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi..");
  }
 
  Serial.println(WiFi.localIP());
 
  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
 
    int paramsNr = request->params();
    Serial.println(paramsNr);
 
    for(int i=0;i<paramsNr;i++){
 
        AsyncWebParameter* p = request->getParam(i);
        Serial.print("Param name: ");
        Serial.println(p->name());
        Serial.print("Param value: ");
        Serial.println(p->value());
        Serial.println("------");
    }
 
    request->send(200, "text/plain", "message received");
  });
 
  server.begin();
}
 
void loop(){}
@Baptou88
Copy link

Hello @UnivespWagnerQueiroz

Replace the line:

AsyncWebParameter* p = request->getParam(i);

by:

const AsyncWebParameter* p = request->getParam(i);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants