getStory method
Fetches a specific Story
Implementation
Future<Story> getStory(int id) async {
try {
Uri url = Uri.parse('$endpoint/item/$id.json');
http.Response res = await _client.get(url);
if (res.statusCode == 200) {
Map<String, dynamic> json = jsonDecode(res.body);
return Story.fromJson(json);
}
throw HackerNewsClientFailure();
} catch (e) {
print('HackerNewsClient.getStory $e');
rethrow;
}
}