patch method

Future<Response> patch(
  1. String url, {
  2. Map? data,
  3. Map<String, String>? headers,
})

Manda una PATCH

Implementation

Future<Response> patch(
  String url, {
  Map? data,
  Map<String, String>? headers,
}) async {
  (headers ??= <String, String>{})
      .putIfAbsent('Content-Type', () => 'application/json');

  try {
    final uri = Uri.parse(url);

    final response = await _client.patch(
      uri,
      body: data == null ? {} : jsonEncode(data),
      headers: headers,
    );

    _printLog(url, response, 'PATCH');
    return response;
  } catch (e) {
    logger.w('[Provider-PATCH] Error on url $url: $e');
    return Response(jsonEncode({'code': 'GENERIC_ERROR'}), 500);
  }
}