fetch function

Future<Response> fetch(
  1. String url, {
  2. String method = 'GET',
  3. Map<String, String>? headers,
  4. String? body,
})

Implementation

Future<Response> fetch(
  String url, {
  String method = 'GET',
  Map<String, String>? headers,
  String? body,
}) {
  // Camino estable: fetch(url)
  if (headers == null && body == null && method == 'GET') {
    return _fetch(url).toDart;
  }

  // Camino con RequestInit COMPLETO
  final init = RequestInit(
    method: method,
    headers: headers!.jsify() as HeadersInit,
    body: body?.toJS,
  );

  return _fetch(url, init).toDart;
}