Skip to content

BasicWithEndpoints example: /yoyo/settings POST doesn't merge custom payload values #74

Description

@davidchatting-bot

Where

`onYoYoMessagePOST()` in `examples/BasicWithEndpoints/BasicWithEndpoints.ino`:
```cpp
//define an alternative to using the built-in /yoyo/credentials endpoint that also allows custom value to be set in the settings doc
if(message["path"] == "/yoyo/settings") {
//TODO: merge settings doc with values from the payload
//(*settings)["name"] = "value";

success = wifiManager.setCredentials(message["payload"]);
if(success) {
(*settings).save();
wifiManager.connect();
message["broadcast"] = true;
}
}
```

Problem

The comment states the intent of this example is to show `/yoyo/settings` accepting custom values in addition to `ssid`/`password`, saved into the same settings document - but the handler only ever calls `wifiManager.setCredentials(message["payload"])`, which just extracts `ssid`/`password` (see #56) and ignores everything else in the payload. So today this example doesn't actually demonstrate what its own comment says it does.

Ask

Merge any extra fields from `message["payload"]` into `*settings` (e.g. iterate the payload's keys and copy non-`ssid`/`password` ones into the settings `JsonDocument`) before calling `.save()`, so the example matches its stated purpose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions