Advertisement
rifki_cs29

apiservice

Sep 24th, 2021
1,167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.42 KB | None | 0 0
  1.   Future<ArticleResult> fetchArticlesCategory(String category) async {
  2.     final response = await http.get(Uri.parse('${baseUrl}top-headlines?country=$country&category=$category&apiKey=$apiKey&pageSize=30'));
  3.     print(response.body);
  4.     print(category);
  5.    if (response.statusCode == 200) {
  6.       return ArticleResult.fromJson(json.decode(response.body));
  7.    } else {
  8.       throw Exception('Failed to load News');
  9.    }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement