Skip to content

Instantly share code, notes, and snippets.

@sergueyarellano
Created May 26, 2021 18:33
Show Gist options
  • Save sergueyarellano/b3cab7d2ec39d78ad5fa7d67f1d70020 to your computer and use it in GitHub Desktop.
Save sergueyarellano/b3cab7d2ec39d78ad5fa7d67f1d70020 to your computer and use it in GitHub Desktop.
const get = require('lodash.get')
const set = require('lodash.set')
const cloneDeep = require('lodash.clonedeep')
const got = require('got')
module.exports = {
makeRequest
}
async function makeRequest (payload) {
const newPayload = cloneDeep(payload)
const { uri, options } = get(newPayload, 'data.request')
const response = await got(uri, options).json()
return set(newPayload, 'data.response.body', response)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment