Ejemplo n.º 1
0
  getApiFetchArgsFromActionPayload(payload, token=null, authenticate=true) {
    let { headers, endpoint, method, body, credentials } = payload;
    if (isUndefined(method)) {
      method = 'GET';
    }

    headers = Object.assign({}, this.defaultHeaders, headers);

    if (token && authenticate) {
      (
        { headers, endpoint, body } = this.addTokenToRequest(
          headers, endpoint, body, token
        )
      );
    }
    if (isFunction(this.preProcessRequest)) {
      (
        { headers, endpoint, body } = this.preProcessRequest(
          headers, endpoint, body
        )
      )
    }

    return [
      endpoint, omitBy({method, body, credentials, headers}, isUndefined)
    ];
  }
Ejemplo n.º 2
0
 .then((u) => {
   let o = utils.chosenFields(u.body)
   o.headers = utils.chosenHeaders(u.headers)
   o = omitBy(o, (d) => !d)
   store[username] = o
   return o
 })
Ejemplo n.º 3
0
  willRespondWith (status, ...other) {
    if (!status) {
      throw new Error('You must provide a status code.')
    }

    this.state['response'] = omitBy({
      status: status,
      headers: other[0] || undefined,
      body: other[1] || undefined
    }, isNil)
    return this
  }
Ejemplo n.º 4
0
  withRequest (method, path, ...other) {
    if (!method) {
      throw new Error('You must provide a HTTP method.')
    }

    if (VALID_METHODS.indexOf(method.toUpperCase()) < 0) {
      throw new Error('You must provide a valid HTTP method.')
    }

    if (!path) {
      throw new Error('You must provide a path.')
    }

    this.state['request'] = omitBy({
      method: method.toUpperCase(),
      path: path,
      query: other[0] || undefined,
      headers: other[1] || undefined,
      body: other[2] || undefined
    }, isNil)
    return this
  }
Ejemplo n.º 5
0
 .then((x) => {
   const out = omitBy(x, (y) => !y)
   delete out.plan
   delete out.headers
   console.log(JSON.stringify(out, null, ' '))
 })
Ejemplo n.º 6
0
const omitByUndefined = (source) => omitBy(source, (value) => typeof value === 'undefined');
Ejemplo n.º 7
0
 _captureProcessProperties() {
   return omitBy(pick(process.env, envKeys), value => !isString(value));
 }