Running Custom Code
Integration Engine allows you to run custom code written in Javascript or Typescript.
You can use it to implement complex logic that is hard to do with mapping and existing abstractions.
Custom code must export a default function (that can be async).
This function will be called with the Execution Context depending on where this function is used.
Custom Code Example
export default async function myCustomFunction(context) {
// Get data from an external app associated with the current integration
const externalData = await context.externalApiClient.get('/some-data')
// Pass this data to your app's API
await context.internalApiClient.post('/some-data', externalData)
}
Logging
Anything you write to stdout will be stored as execution logs of the custom code. The simplest way to do it is to use console.log
:
export default function myCustomFunction() {
console.log('Hello, world!')
}
If you want to output complex data, you should JSON-serialize it:
export default function myCustomFunction() {
console.log(JSON.stringify({hello: 'world'}))
}
Updated 16 days ago