smartrequest/dist/index.js

45 lines
3.8 KiB
JavaScript
Raw Normal View History

2017-01-28 23:51:47 +00:00
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
2017-06-09 19:48:16 +00:00
Object.defineProperty(exports, "__esModule", { value: true });
2017-01-28 23:51:47 +00:00
const smartrequest_request_1 = require("./smartrequest.request");
2017-01-29 00:12:42 +00:00
var smartrequest_request_2 = require("./smartrequest.request");
exports.request = smartrequest_request_2.request;
2017-01-28 23:51:47 +00:00
exports.get = (domainArg, optionsArg = {}) => __awaiter(this, void 0, void 0, function* () {
optionsArg.method = 'GET';
let response = yield smartrequest_request_1.request(domainArg, optionsArg);
return response;
});
exports.post = (domainArg, optionsArg = {}) => __awaiter(this, void 0, void 0, function* () {
optionsArg.method = 'POST';
2018-06-13 20:34:49 +00:00
if (typeof optionsArg.requestBody === 'object' &&
(!optionsArg.headers || !optionsArg.headers['Content-Type'])) {
// make sure headers exist
if (!optionsArg.headers) {
optionsArg.headers = {};
}
// assign the right Content-Type, leaving all other headers in place
Object.assign(optionsArg.headers, {
'Content-Type': 'application/json'
});
}
2017-01-28 23:51:47 +00:00
let response = yield smartrequest_request_1.request(domainArg, optionsArg);
return response;
});
exports.put = (domainArg, optionsArg = {}) => __awaiter(this, void 0, void 0, function* () {
optionsArg.method = 'PUT';
let response = yield smartrequest_request_1.request(domainArg, optionsArg);
return response;
});
exports.del = (domainArg, optionsArg = {}) => __awaiter(this, void 0, void 0, function* () {
optionsArg.method = 'DELETE';
let response = yield smartrequest_request_1.request(domainArg, optionsArg);
return response;
});
2018-06-13 20:34:49 +00:00
//# sourceMapping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