import 'package:dio/dio.dart'; import 'package:server/apis/auth.dart'; import 'package:server/client.dart'; class Cart { String lastError = ''; addToCart() async { try { final id = await auth.setToken(); if (id != null) { final response = await api.post( '/collections/cart/records', data: {'user_id': id, 'product_id': 'string', 'count': 10}, ); if (response.data != null) { return 'Well done'; } } } on DioException catch (e) { if (e.type == DioExceptionType.connectionError) { return "Internet Connection Error"; } return e.response!.data['message']; } catch (e) { print(e); return Error(); } } }