webhook-action/dist/http.js

29 lines
900 B
JavaScript
Raw Normal View History

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.http = void 0;
var fetch = require('node-fetch');
var Http = (function () {
function Http() {
}
Http.prototype.make = function (url, headers, body) {
var _this = this;
return new Promise(function (resolve, reject) {
fetch(url, _this.getOptions('post', headers, body))
.then(function (res) { return resolve(res); });
});
};
Http.prototype.getOptions = function (method, headers, body) {
var options = {
2020-08-26 00:41:58 +00:00
headers: headers ? JSON.parse(headers) : {},
method: method
};
2020-08-26 00:41:58 +00:00
if (body) {
options.body = body;
}
options.headers['content-type'] = 'application/json';
return options;
};
return Http;
}());
exports.http = new Http();
//# sourceMappingURL=http.js.map