zemberekAPI method

Future<String> zemberekAPI(
  1. String endpoint,
  2. String body
)

zemberekAPI is a class for making HTTP requests to the ZEMBEREK API using the endpoint and body parameter.

Implementation

Future<String> zemberekAPI(String endpoint, String body) async {
  try {
    var url = (Uri.parse('$ipAdresi:$port/$endpoint'));
    var res = await http.post(url, body: body);
    var body1 = res.body;
    var decoded = jsonDecode(body1);
    return decoded;
  } catch (e) {
    var hata = e.toString();
    if (hata.contains('NoSuchMethodError')) {
      var sozlukanlam = "Probably System Error. Open an issue on GitHub.";
      return sozlukanlam;
    } else {
      var sozlukanlam = e.toString();
      return sozlukanlam;
    }
  }
}