31 lines
750 B
Dart
31 lines
750 B
Dart
// ignore_for_file: unnecessary_brace_in_string_interps
|
|
|
|
import 'package:dio/dio.dart';
|
|
import 'package:server/apis/auth.dart';
|
|
import 'package:server/client.dart';
|
|
|
|
class Shop {
|
|
String lastError = '';
|
|
getCatalog() async {
|
|
await auth.setToken();
|
|
try {
|
|
final response = await api.get('collections/products/records');
|
|
if (response.data != null) {
|
|
return response.data;
|
|
} else {
|
|
return Error();
|
|
}
|
|
} on DioException catch (e) {
|
|
if (e.type == DioExceptionType.connectionError) {
|
|
lastError = 'Internet Connection errror';
|
|
}
|
|
lastError = e.response!.data['message'];
|
|
} catch (e) {
|
|
print('empty error');
|
|
return 'empty errror';
|
|
}
|
|
}
|
|
}
|
|
|
|
final shop = Shop();
|