Return array instead of null from api

[MAILPOET-2518]
This commit is contained in:
Pavel Dohnal
2020-07-14 10:25:23 +02:00
committed by Veljko V
parent 5de4985da2
commit 405476cb7b
2 changed files with 6 additions and 7 deletions

View File

@ -30,14 +30,13 @@ abstract class Response {
if (!empty($this->meta)) {
$response['meta'] = $this->meta;
}
if ($data !== null) {
$response = array_merge($response, $data);
if ($data === null) {
$data = [];
}
$response = array_merge($response, $data);
if (!empty($response)) {
@header('Content-Type: application/json; charset=' . get_option('blog_charset'));
echo WPFunctions::get()->wpJsonEncode($response);
}
@header('Content-Type: application/json; charset=' . get_option('blog_charset'));
echo WPFunctions::get()->wpJsonEncode($response);
die();
}

View File

@ -11,7 +11,7 @@ class SuccessResponse extends Response {
}
public function getData() {
if ($this->data === null) return null;
if ($this->data === null) return [];
return [
'data' => $this->data,