Skip to content

Commit

Permalink
Correction to http_request example (#4543)
Browse files Browse the repository at this point in the history
The affected example code caused two errors:
- a `no return statement in function returning non-void [-Werror=return-type]` caused by missing `return`s within the `if`s.
- `while parsing a block mapping ... expected <block end>, but found '<scalar>'` caused by the `;` at the end of `args`
  • Loading branch information
nagyrobi authored Dec 28, 2024
1 parent d6bb477 commit 0a8a374
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions components/http_request.rst
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,19 @@ whose ``id`` is set to ``player_volume``:
then:
- lambda: |-
json::parse_json(body, [](JsonObject root) -> bool {
if (root["vol"]) {
id(player_volume).publish_state(root["vol"]);
} else {
ESP_LOGD(TAG,"No 'vol' key in this json!");
}
if (root["vol"]) {
id(player_volume).publish_state(root["vol"]);
return true;
}
else {
ESP_LOGI(TAG,"No 'vol' key in this json!");
return false;
}
});
else:
- logger.log:
format: "Error: Response status: %d, message %s"
args: [response->status_code, body.c_str()];
args: [ 'response->status_code', 'body.c_str()' ]
See Also
--------
Expand Down

0 comments on commit 0a8a374

Please sign in to comment.