Skip to content

Commit

Permalink
filter news from beyondtheflag #42
Browse files Browse the repository at this point in the history
  • Loading branch information
BrightDV committed Jan 2, 2023
1 parent 2b84ed2 commit a2bbb54
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/api/mixed_news.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ import 'package:http/http.dart' as http;

class Wordpress {
Future<List> getWordpressNews(String baseUrl, {int? max}) async {
late Uri url;
List formatedNews = [];
var url = Uri.parse('$baseUrl/wp-json/wp/v2/posts');
baseUrl == 'https://beyondtheflag.com'
? url = Uri.parse('$baseUrl/wp-json/wp/v2/posts?categories=270521,0')
: url = Uri.parse('$baseUrl/wp-json/wp/v2/posts');
var response = await http.get(url);
List responseAsJson = jsonDecode(
response.body,
Expand All @@ -37,7 +40,13 @@ class Wordpress {
}

Future<List> getMoreWordpressNews(String baseUrl, int offset) async {
var url = Uri.parse('$baseUrl/wp-json/wp/v2/posts?offset=$offset');
late Uri url;

baseUrl == 'https://beyondtheflag.com'
? url = Uri.parse(
'$baseUrl/wp-json/wp/v2/posts?offset=$offset&categories=270521,0',
)
: url = Uri.parse('$baseUrl/wp-json/wp/v2/posts?offset=$offset');
var response = await http.get(url);
List responseAsJson = jsonDecode(
response.body,
Expand Down

0 comments on commit a2bbb54

Please sign in to comment.