// To use any npm package, just import it
// using Axios for HTTP
import axios from "axios"
export default defineComponent({
async run({ steps, $ }) {
// "tenantID" value expected in POST request
const tenantID = steps.trigger.event.body.tenantID
const env = "gus-training"
//env
const tenantEndpoint = "https://"+env+".TEST.com/TEST/api/"+tenantID
//Init token
var access_token = steps.access_token.$return_value
// Get the config from a tenant
console.log("getting Config")
console.log(tenantEndpoint)
async function getConfig() {
// Get the config from a tenant
console.log("getting Config");
const { conf } = await axios({
method: "GET",
headers: {
'Content-Type': 'application/JSON',
'Authorization': "Bearer " + access_token,
'Accept': "*/*",
},
url: tenantEndpoint + "/configure/_noInheritance",
});
return conf
}
var config = await getConfig()
console.log(config)
var sourceArray = config.sources.filter(function (source) {
return source.label == "CRM"
});
await $.respond({
status: 200,
headers: {},
body: {access_token: access_token, CRM: sourceArray},
})
},
})
When I run the above, I get an error: Cannot read property ‘sources’ of undefined
I take this to mean the promise of conf
doesn’t resolve. I want to work with the data in conf
in the rest of the code/workflow.
I do expect conf
to be relatively large (300-400kb).
Can anyone help me understand why this is happening and how to fix it?
I have identical axios calls that do successfully resolve (although with much smaller data amounts), so I’m confused why this is happening here.