Allow optional headers & body

This commit is contained in:
Joel Male
2020-08-26 10:41:58 +10:00
parent 5be5ae3f9a
commit d3ff660fa9
12 changed files with 22 additions and 16 deletions
+6 -4
View File
@@ -312,10 +312,12 @@ var Http = (function () {
};
Http.prototype.getOptions = function (method, headers, body) {
var options = {
headers: JSON.parse(headers),
headers: headers ? JSON.parse(headers) : {},
method: method
};
options.body = JSON.stringify(body);
if (body) {
options.body = body;
}
options.headers['content-type'] = 'application/json';
return options;
};
@@ -2132,8 +2134,8 @@ function run() {
var url, headers, body;
return __generator(this, function (_c) {
url = core.getInput('url');
headers = (_a = core.getInput('headers')) !== null && _a !== void 0 ? _a : '';
body = (_b = core.getInput('body')) !== null && _b !== void 0 ? _b : '';
headers = (_a = core.getInput('headers')) !== null && _a !== void 0 ? _a : null;
body = (_b = core.getInput('body')) !== null && _b !== void 0 ? _b : null;
core.info("Sending webhook request to " + url);
core.debug((new Date()).toTimeString());
http_1.http.make(url, headers, body)