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
+4 -2
View File
@@ -14,10 +14,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;
};