2020-08-25 23:36:04 +00:00
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
exports.http = void 0;
|
2020-08-26 00:20:01 +00:00
|
|
|
var fetch = require('node-fetch');
|
2020-08-25 23:36:04 +00:00
|
|
|
var Http = (function () {
|
|
|
|
function Http() {
|
|
|
|
}
|
|
|
|
Http.prototype.make = function (url, headers, body) {
|
2020-08-26 00:31:06 +00:00
|
|
|
var _this = this;
|
2020-08-26 00:34:42 +00:00
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
fetch(url, _this.getOptions('post', headers, body))
|
|
|
|
.then(function (res) { return resolve(res); });
|
2020-08-25 23:36:04 +00:00
|
|
|
});
|
|
|
|
};
|
2020-08-26 00:20:01 +00: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-25 23:36:04 +00:00
|
|
|
};
|
|
|
|
return Http;
|
|
|
|
}());
|
|
|
|
exports.http = new Http();
|
|
|
|
//# sourceMappingURL=http.js.map
|