fetch function

Future<Response> fetch(
  1. Resource resource, {
  2. String? method,
  3. Headers? headers,
  4. Object? body,
  5. String? referrer,
  6. ReferrerPolicy? referrerPolicy,
  7. RequestMode? mode,
  8. RequestCredentials? credentials,
  9. RequestCache? cache,
  10. RequestRedirect? redirect,
  11. String? integrity,
  12. bool? keepalive,
  13. AbortSignal? signal,
})

Implementation

Future<Response> fetch(Resource resource,
    {String? method,
    Headers? headers,
    Object? body,
    String? referrer,
    interop.ReferrerPolicy? referrerPolicy,
    interop.RequestMode? mode,
    interop.RequestCredentials? credentials,
    interop.RequestCache? cache,
    interop.RequestRedirect? redirect,
    String? integrity,
    bool? keepalive,
    AbortSignal? signal}) async {
  var response = await interop.fetch(
    interop.requestFromResource(resource),
    interop.RequestInit(
        method: method,
        headers: headers?.delegate,
        body: body,
        referrer: referrer,
        referrerPolicy: referrerPolicy,
        mode: mode,
        credentials: credentials,
        cache: cache,
        redirect: redirect,
        integrity: integrity,
        keepalive: keepalive,
        signal: signal?.delegate),
  );
  try {
    return responseFromJsObject(
      await promiseToFuture(response),
    );
  } catch (e) {
    return responseFromJsObject(response);
  }
}