How to use the cross-fetch.Request function in cross-fetch

To help you get started, we’ve selected a few cross-fetch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github badgateway / ketting / src / utils / fetch-helper.ts View on Github external
if (init) {
    Object.assign(trueInit, defaultInit, init);
  } else {
    Object.assign(trueInit, defaultInit);
  }

  trueInit.headers = mergeHeaders([
    defaultInit.headers,
    // @ts-ignore cross-fetch definitions are broken. See https://github.com/lquixada/cross-fetch/pull/19
    input instanceof crossFetch.Request ? input.headers : null,
    init && init.headers ? init.headers : null
  ]);

    // @ts-ignore cross-fetch definitions are broken. See https://github.com/lquixada/cross-fetch/pull/19
  return new crossFetch.Request(input, trueInit);

}
github badgateway / ketting / src / resource.js View on Github external
// in newInit.
    if (init) {
      for(var key in init) {
        if (key==='headers') {
          // special case.
          continue;
        }
        newInit[key] = init[key];
      }
      newInit.headers = mergeHeaders([
        newInit.headers,
        init.headers
      ]);
    }

    var request = new fetch.Request(uri, newInit);

    return this.client.fetch(request);

  },
github AEB-labs / graphql-weaver / src / graphql-client / http-client.ts View on Github external
protected async getRequest(document: DocumentNode, variables?: { [name: string]: any }, context?: any, introspect?: boolean): Promise {
        return new Request(this.url, {
            method: 'POST',
            headers: await this.getHeaders(document, variables, context, introspect),
            body: await this.getBody(document, variables, context)
        });
    }