mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
fix issue where OK was not sent on successfull API call
This commit is contained in:
@@ -91,8 +91,10 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject & input) {
|
|||||||
ret_code = 400; // Bad request
|
ret_code = 400; // Bad request
|
||||||
} else if (command_ret == CommandRet::OK) {
|
} else if (command_ret == CommandRet::OK) {
|
||||||
ret_code = 200; // OK
|
ret_code = 200; // OK
|
||||||
if (output.isNull()) {
|
// if there was not json output from the call, default to the message 'OK'.
|
||||||
output["message"] = "OK"; // only add if there is no json output already
|
// this will be used for example when calling endpoints e.g. /api/thermostat/temp
|
||||||
|
if (!output.size()) {
|
||||||
|
output["message"] = "OK";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ret_code = 400; // Bad request
|
ret_code = 400; // Bad request
|
||||||
@@ -108,7 +110,7 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject & input) {
|
|||||||
Serial.print(COLOR_YELLOW);
|
Serial.print(COLOR_YELLOW);
|
||||||
Serial.print("return code: ");
|
Serial.print("return code: ");
|
||||||
Serial.println(ret_code);
|
Serial.println(ret_code);
|
||||||
if (output.size() != 0) {
|
if (output.size()) {
|
||||||
serializeJsonPretty(output, Serial);
|
serializeJsonPretty(output, Serial);
|
||||||
}
|
}
|
||||||
Serial.println();
|
Serial.println();
|
||||||
|
|||||||
Reference in New Issue
Block a user