transformRequest method

  1. @override
Future<String> transformRequest(
  1. RequestOptions options
)
inherited

transformRequest allows changes to the request data before it is sent to the server, but after the RequestInterceptor.

This is only applicable for request methods 'PUT', 'POST', and 'PATCH'

Implementation

@override
Future<String> transformRequest(RequestOptions options) async {
  final dynamic data = options.data ?? '';
  if (data is! String && Transformer.isJsonMimeType(options.contentType)) {
    return jsonEncodeCallback(data);
  } else if (data is Map) {
    return Transformer.urlEncodeMap(data);
  } else {
    return data.toString();
  }
}