fetch method

Future fetch(
  1. dynamic input, [
  2. Map? init
])

Implementation

Future fetch(dynamic input, [Map? init]) {
  final method = (init != null && init['method'] is String)
      ? init['method'] as String
      : 'GET';

  if (input is Uri) {
    return HttpRequest.request(input.toString(), method: method);
  }
  if (input is String) {
    return HttpRequest.request(input, method: method);
  }

  return Future.error(
    UnsupportedError('Unsupported fetch input type: ${input.runtimeType}'),
  );
}