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