How do I get the request params from a ESPAsyncWebServer? I currently have the following code

server.on("/on", HTTP_POST, [](AsyncWebServerRequest *request) {
    Serial.println("ON hit.");
    String message;
    Serial.println(request-&gt;url());
    if (request-&gt;hasParam("device"))
    {
        message = request-&gt;getParam("device")-&gt;value();
    }
    else
    {
        message = " not specified";
    }
    request-&gt;send(200, "text/plain", "On, GET: " + message);
    Serial.print("Device ");
    Serial.println(message);
....


When sending in a request I get the out put, "Device not specified".

I take a look at the request-params() which gives me back a count of params that are in there and it's returning 1. I write this out:

server.on("/off", HTTP_POST, [](AsyncWebServerRequest *request) {
    Serial.println("OFF hit.");
    String message;
    int params = request-&gt;params();
    Serial.printf("%d params sent in\n", params);
    for (int i = 0; i &lt; params; i++)
    {
        AsyncWebParameter *p = request-&gt;getParam(i);
        if (p-&gt;isFile())
        {
            Serial.printf("_FILE[%s]: %s, size: %u", p-&gt;name().c_str(), p-&gt;value().c_str(), p-&gt;size());
        }
        else if (p-&gt;isPost())
        {
            Serial.printf("_POST[%s]: %s", p-&gt;name().c_str(), p-&gt;value().c_str());
        }
        else
        {
            Serial.printf("_GET[%s]: %s", p-&gt;name().c_str(), p-&gt;value().c_str());
        }
    }
    if (request-&gt;hasParam("device"))
    {
        message = request-&gt;getParam("device")-&gt;value();
    }
    else
    {
        message = "not specified";
    }
    request-&gt;send(200, "text/plain", "Off, GET: " + message);
    Serial.print("Device ");
    Serial.println(message);


and get the output now of

1 params sent in
_POST[device]: puddle
Device not specified  


If I try to do something like request->getParam(0)->value().c_str()
I get a stack dump of a bunch of hex values that I have no idea what it means: but it looks like a big fat error.
For POST request the hasParam needs to know if you want to test the url parameters or x-www-form-urlencoded parameters in body of the POST request. The second parameter of the hasParam is boolean post and it has default value false. Use hasParam("device", true).