Skip to content

Commit 3e265f9

Browse files
authored
Correction to http_request example
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`
1 parent d6bb477 commit 3e265f9

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

components/http_request.rst

+9-6
Original file line numberDiff line numberDiff line change
@@ -291,16 +291,19 @@ whose ``id`` is set to ``player_volume``:
291291
then:
292292
- lambda: |-
293293
json::parse_json(body, [](JsonObject root) -> bool {
294-
if (root["vol"]) {
295-
id(player_volume).publish_state(root["vol"]);
296-
} else {
297-
ESP_LOGD(TAG,"No 'vol' key in this json!");
298-
}
294+
if (root["vol"]) {
295+
id(player_volume).publish_state(root["vol"]);
296+
return true;
297+
}
298+
else {
299+
ESP_LOGI(TAG,"No 'vol' key in this json!");
300+
return false;
301+
}
299302
});
300303
else:
301304
- logger.log:
302305
format: "Error: Response status: %d, message %s"
303-
args: [response->status_code, body.c_str()];
306+
args: [ 'response->status_code', 'body.c_str()' ]
304307
305308
See Also
306309
--------

0 commit comments

Comments
 (0)