getJson method
getJson is a class for making HTTP requests to the SOZLUK API using the word parameter.
Implementation
Future<String> getJson(String word) async {
try {
final res = await _get(_gtsUri(word));
var body = res.body;
var decoded = jsonDecode(body);
var json = decoded[0];
var sozlukanlam = json;
return sozlukanlam.toString();
} on NoSuchMethodError {
throw StateError("ERR-004 - Couldn't find any json with this word.");
} catch (e) {
throw Exception("Failed to fetch json for '$word': $e");
}
}