mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
27 lines
850 B
Dart
27 lines
850 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:syncrow_web/pages/device_managment/models/devices_model.dart';
|
|
import 'package:syncrow_web/services/api/http_service.dart';
|
|
import 'package:syncrow_web/utils/constants/api_const.dart';
|
|
|
|
class DevicesManagementApi {
|
|
Future<List<AllDevicesModel>> fetchDevices() async {
|
|
try {
|
|
final response = await HTTPService().get(
|
|
path: ApiEndpoints.getAllDevices,
|
|
showServerMessage: true,
|
|
expectedResponseModel: (json) {
|
|
List<dynamic> jsonData = json;
|
|
List<AllDevicesModel> devicesList = jsonData.map((jsonItem) {
|
|
return AllDevicesModel.fromJson(jsonItem);
|
|
}).toList();
|
|
return devicesList;
|
|
},
|
|
);
|
|
return response;
|
|
} catch (e) {
|
|
debugPrint('Error fetching $e');
|
|
return [];
|
|
}
|
|
}
|
|
}
|