diff options
author | Daniel Lange <DLange@git.local> | 2023-01-11 16:05:06 +0100 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2023-01-11 16:05:06 +0100 |
commit | 6d21b208b9cfae0941bebf59b39ee04f6002b4f9 (patch) | |
tree | 43fd71c7464eaecba172810d000dc2e426bd8d94 /htdocs | |
parent | 39154d99acf0359638be5d5efd51e44f5b803e4b (diff) | |
download | stikked-fit-6d21b208b9cfae0941bebf59b39ee04f6002b4f9.tar.gz stikked-fit-6d21b208b9cfae0941bebf59b39ee04f6002b4f9.tar.bz2 stikked-fit-6d21b208b9cfae0941bebf59b39ee04f6002b4f9.zip |
Fix the API in case of empty arrays and fix the /langs endpoint
Diffstat (limited to 'htdocs')
-rw-r--r-- | htdocs/application/controllers/Api.php | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/htdocs/application/controllers/Api.php b/htdocs/application/controllers/Api.php index 74aac22..948ed24 100644 --- a/htdocs/application/controllers/Api.php +++ b/htdocs/application/controllers/Api.php @@ -132,7 +132,7 @@ class Api extends Main } $this->load->model('pastes'); $pastes = $this->pastes->getLists('api/recent'); - $pastes = $pastes['pastes']; + $pastes = $pastes['pastes'] ?? []; $data = array(); foreach ($pastes as $paste) { $data[] = array( @@ -158,7 +158,7 @@ class Api extends Main } $this->load->model('pastes'); $pastes = $this->pastes->getTrends('api/trending', 2); - $pastes = $pastes['pastes']; + $pastes = $pastes['pastes'] ?? []; $data = array(); foreach ($pastes as $paste) { $data[] = array( @@ -180,6 +180,8 @@ class Api extends Main } $languages = $this->languages->get_languages(); + // remove the 0 --- divider between favorite languages and the rest + unset($languages["0"]); echo json_encode($languages); } } |