Browse Source

Fix API clients to handle paginated responses

Backend returns { items: [], total: N } format but frontend expected plain arrays.
Updated all API clients to extract nested arrays:
- organizations.js: return data.organizations || []
- devices.js: return data.devices || [] (both superadmin and client endpoints)
- users.js: return data.users || [] (both superadmin and client endpoints)

Fixes issue where organizations/devices/users were not loading in admin interface.
root 1 month ago
parent
commit
a8481843d9
3 changed files with 4 additions and 4 deletions
  1. 2 2
      frontend/src/api/devices.js
  2. 1 1
      frontend/src/api/organizations.js
  3. 1 1
      frontend/src/api/users.js

+ 2 - 2
frontend/src/api/devices.js

@@ -4,7 +4,7 @@ export default {
   // Superadmin endpoints
   async getAllSuperadmin() {
     const { data } = await client.get('/superadmin/devices')
-    return data
+    return data.devices || []
   },
 
   async getByIdSuperadmin(id) {
@@ -25,7 +25,7 @@ export default {
   // Client endpoints
   async getAllClient() {
     const { data } = await client.get('/client/devices')
-    return data
+    return data.devices || []
   },
 
   async getByIdClient(id) {

+ 1 - 1
frontend/src/api/organizations.js

@@ -3,7 +3,7 @@ import client from './client'
 export default {
   async getAll() {
     const { data } = await client.get('/superadmin/organizations')
-    return data
+    return data.organizations || []
   },
 
   async getById(id) {

+ 1 - 1
frontend/src/api/users.js

@@ -4,7 +4,7 @@ export default {
   // Superadmin endpoints
   async getAllSuperadmin() {
     const { data } = await client.get('/superadmin/users')
-    return data
+    return data.users || []
   },
 
   async getByIdSuperadmin(id) {