makepost method

Request makepost(
  1. String route, {
  2. Map<String, String>? headers,
  3. String? body,
  4. Encoding? encoding,
})

make an actual API request to a route, and always append the API_KEY as authorization-header

Implementation

http.Request makepost(
  String route, {
  Map<String, String>? headers,
  String? body,
  Encoding? encoding,
}) {
  headers = headers ?? {};
  headers.addAll({HttpHeaders.authorizationHeader: _api_key});
  var fullURL = Uri.parse(_baseurl + route);
  final req = http.Request('post', fullURL)..headers.addAll(headers);
  if (encoding != null) req.encoding = encoding;
  if (body != null) req.body = body;
  return req;
}