flutter_service/lib/service/CategoryService.dart

20 lines
566 B
Dart
Raw Permalink Normal View History

2021-03-01 22:16:41 +07:00
import 'package:flutter_service/config/DiConfig.dart';
import 'package:flutter_service/model/CategoryResponse.dart';
Future<List<CategoryResponse>> getAllCategoryService() async {
String url = "http://computer-api.osa.cubetiqs.com/api/frontend/categories";
List<CategoryResponse> r = await getDioInstance().get(url).then((value) {
List<dynamic> result = value.data['data'] as List<dynamic>;
return result.map((e) => CategoryResponse.fromResponse(e)).toList();
}).catchError((onError) {
print(onError);
return null;
});
return r;
}