20 lines
566 B
Dart
20 lines
566 B
Dart
|
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;
|
||
|
|
||
|
}
|