Platform
ESP32
IDE / Tooling
PlatformIO
What happened?
request->params() returns 0 when used in void handleRequest(AsyncWebServerRequest *request) inside custom handler derived from AsyncWebHandler.
Stack Trace
Minimal Reproductible Example (MRE)
- Create custom handler:
class CustomHandler: public AsyncWebHandler {
public:
CustomHandler() {}
virtual ~CustomHandler() {}
bool canHandle(__unused AsyncWebServerRequest *request) const override {
return request->method() == HTTP_POST;
}
void handleRequest(AsyncWebServerRequest *request) {
if (request->method() == HTTP_POST) {
int params = request->params();
Serial.println(params);
}
}
};
- Add a handler to the server:
AsyncWebServer server(80);
int main() {
server.addHandler(new CustomHandler());
server.begin();
}
- Send a POST request with some form data.
I confirm that:
Platform
ESP32
IDE / Tooling
PlatformIO
What happened?
request->params()returns0when used invoid handleRequest(AsyncWebServerRequest *request)inside custom handler derived fromAsyncWebHandler.Stack Trace
Minimal Reproductible Example (MRE)
I confirm that: