Created
May 26, 2021 18:33
-
-
Save sergueyarellano/b3cab7d2ec39d78ad5fa7d67f1d70020 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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