feat: product scroll infinity
This commit is contained in:
@@ -13,17 +13,27 @@ import 'auth_local_datasource.dart';
|
||||
class ProductRemoteDatasource {
|
||||
final Dio dio = DioClient.instance;
|
||||
|
||||
Future<Either<String, ProductResponseModel>> getProducts() async {
|
||||
Future<Either<String, ProductResponseModel>> getProducts({
|
||||
int page = 1,
|
||||
int limit = Variables.defaultLimit,
|
||||
String? categoryId,
|
||||
}) async {
|
||||
try {
|
||||
final authData = await AuthLocalDataSource().getAuthData();
|
||||
final url = '${Variables.baseUrl}/api/v1/products';
|
||||
|
||||
Map<String, dynamic> queryParameters = {
|
||||
'page': page,
|
||||
'limit': limit,
|
||||
};
|
||||
|
||||
if (categoryId != null) {
|
||||
queryParameters['category_id'] = categoryId;
|
||||
}
|
||||
|
||||
final response = await dio.get(
|
||||
url,
|
||||
queryParameters: {
|
||||
'page': 1,
|
||||
'limit': 30,
|
||||
},
|
||||
queryParameters: queryParameters,
|
||||
options: Options(
|
||||
headers: {
|
||||
'Authorization': 'Bearer ${authData.token}',
|
||||
|
||||
Reference in New Issue
Block a user