import 'package:dio/dio.dart'; import 'package:server/apis/auth.dart'; import 'package:server/client.dart'; class Orders { String lastError = ''; createOrder(productId, count) async { final userId = await auth.setToken(); try { final response = await api.post( '/collections/orders/records', data: {'user_id': userId, 'product_id': productId, 'count': count}, ); if (response.data != null) { return response.data; } } on DioException catch (e) { if (e.type == DioExceptionType.connectionError) { lastError = 'Internet Connection Error'; } else { lastError = e.response!.data['message']; } } } } final orders = Orders();