Created
September 1, 2022 19:22
-
-
Save nicodoss/dfce1e1f8cfc565898cb1ff424cd23c9 to your computer and use it in GitHub Desktop.
LivresServices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:convert'; | |
import 'package:dio/dio.dart'; | |
import '../../Globales/BaseUrl.dart'; | |
import '../modules/livres/models/livres.dart'; | |
class LivreServices { | |
Future<List<Livres>>? getListLivresByAuteurs(List<String> idAuteurs) async { | |
List<Livres> lstLivres = []; | |
String appendString = ""; | |
for (String p in idAuteurs) { | |
appendString = idAuteurs.join("&auteursIds="); | |
} | |
// String url= | |
try { | |
Dio dio = new Dio(); | |
print('------------------Livres Service-----------'); | |
print(BaseUrl.urlApi + "/booksByListAuteur/?auteursIds=$appendString"); | |
final response = await dio | |
.get(BaseUrl.urlApi + "/booksByListAuteur/?auteursIds=$appendString"); | |
final jsonresponse = jsonDecode(response.data); | |
for (var p in jsonresponse['object'] as List<Map<String, dynamic>>) { | |
lstLivres.add(Livres.fromJson(p['object'])); | |
} | |
} catch (e) { | |
print("error"); | |
print(e); | |
} | |
return lstLivres; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment