Last active
September 7, 2023 17:12
-
-
Save ctrlaltdylan/54436d077a509d2471c709d44f01b855 to your computer and use it in GitHub Desktop.
Pipedream HTTP response component
This file contains 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
// To return a custom HTTP response, use $.respond() [requires HTTP trigger] | |
export default defineComponent({ | |
props: { | |
body: { | |
type: 'object', | |
label: "Body", | |
description: "The payload to respond with", | |
default: {} | |
}, | |
headers: { | |
type: 'object', | |
label: "Headers", | |
description: "The headers to respond with", | |
optional: true, | |
}, | |
status: { | |
type: 'integer', | |
label: "Status", | |
description: "The HTTP status to response with", | |
default: 200, | |
} | |
}, | |
name: 'Return an HTTP response', | |
key: 'http-response', | |
version: '0.0.1', | |
type: 'action', | |
async run({ steps, $ }) { | |
await $.respond({ | |
status: this.status, | |
headers: this.headers || {}, | |
body: this.body, | |
}) | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use this component code in Pipedream, simply paste it into a Node.js code step.
If you'd like to reuse it for other workflows without having to repaste it, click the menu in the top right and select Publish to my Actions.
This will publish this component to your Pipedream account, so you can reuse it in other workflows.