post static method

Future<Response> post({
  1. required Uri url,
  2. required String body,
  3. Map<String, String>? headers,
})

Implementation

static Future<http.Response> post({
  required Uri url,
  required String body,
  Map<String, String>? headers,
}) async {
  if (JwtDecoder.isExpired(Config.accessToken)) {
    await Config.refreshAccessToken();
  }

  var headersToBeSent = <String, String>{
    "Authorization": "Bearer ${Config.accessToken}",
    "Content-Type": "application/json"
  };

  if (headers != null && headers.isNotEmpty) {
    headersToBeSent.addAll(headers);
  }

  var response = await http.post(
    url,
    headers: headersToBeSent,
    body: body,
  );

  return response;
}