add headers input in outgoing webhook automation step

This commit is contained in:
Maurits Lourens 2021-08-03 22:39:01 +02:00
parent 92b415d109
commit 3029178eeb
1 changed files with 11 additions and 1 deletions

View File

@ -27,6 +27,7 @@ module.exports.definition = {
requestMethod: "POST",
url: "http://",
requestBody: "{}",
headers: "{}",
},
schema: {
inputs: {
@ -45,6 +46,11 @@ module.exports.definition = {
title: "JSON Body",
customType: "wide",
},
headers: {
type: "string",
title: "Headers",
customType: "wide",
},
},
required: ["requestMethod", "url"],
},
@ -65,7 +71,7 @@ module.exports.definition = {
}
module.exports.run = async function ({ inputs }) {
let { requestMethod, url, requestBody } = inputs
let { requestMethod, url, requestBody, headers } = inputs
if (!url.startsWith("http")) {
url = `http://${url}`
}
@ -84,6 +90,10 @@ module.exports.run = async function ({ inputs }) {
request.headers = {
"Content-Type": "application/json",
}
if (headers && headers.length !== 0) {
request.headers = { ...request.headers, ...JSON.parse(headers) }
}
}
try {