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) ]; }
.then((u) => { let o = utils.chosenFields(u.body) o.headers = utils.chosenHeaders(u.headers) o = omitBy(o, (d) => !d) store[username] = o return o })
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 }
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 }
.then((x) => { const out = omitBy(x, (y) => !y) delete out.plan delete out.headers console.log(JSON.stringify(out, null, ' ')) })
const omitByUndefined = (source) => omitBy(source, (value) => typeof value === 'undefined');
_captureProcessProperties() { return omitBy(pick(process.env, envKeys), value => !isString(value)); }