Return array instead of null from api
[MAILPOET-2518]
This commit is contained in:
@ -30,14 +30,13 @@ abstract class Response {
|
|||||||
if (!empty($this->meta)) {
|
if (!empty($this->meta)) {
|
||||||
$response['meta'] = $this->meta;
|
$response['meta'] = $this->meta;
|
||||||
}
|
}
|
||||||
if ($data !== null) {
|
if ($data === null) {
|
||||||
$response = array_merge($response, $data);
|
$data = [];
|
||||||
}
|
}
|
||||||
|
$response = array_merge($response, $data);
|
||||||
|
|
||||||
if (!empty($response)) {
|
@header('Content-Type: application/json; charset=' . get_option('blog_charset'));
|
||||||
@header('Content-Type: application/json; charset=' . get_option('blog_charset'));
|
echo WPFunctions::get()->wpJsonEncode($response);
|
||||||
echo WPFunctions::get()->wpJsonEncode($response);
|
|
||||||
}
|
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ class SuccessResponse extends Response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getData() {
|
public function getData() {
|
||||||
if ($this->data === null) return null;
|
if ($this->data === null) return [];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'data' => $this->data,
|
'data' => $this->data,
|
||||||
|
Reference in New Issue
Block a user