Update http.js, app/index.js

This commit is contained in:
Namhyeon Go 2020-11-12 13:36:16 +09:00
parent a5f60b1409
commit 4ec0d79860
2 changed files with 30 additions and 9 deletions

View File

@ -106,18 +106,17 @@ var getLocalApplications = function() {
console.log("반영되었습니다."); console.log("반영되었습니다.");
} }
}; };
if (applicationId) { if (applicationId) {
req = $.ajax({ HTTP.create()
type: "PATCH", .setContentType("application/json-patch+json")
url: apiUrl + "/netsolid/items/applications/" + applicationId, .setRequestBody(JSON.stringify(data))
data: JSON.stringify(data), .patch(apiUrl + "/netsolid/items/applications/" + applicationId, onSuccess)
contentType: 'application/json-patch+json', ;
success: onSuccess
});
} else { } else {
HTTP.create() HTTP.create()
.setContentType("application/json") .setContentType("application/json")
.setBearerAuth(token)
.setRequestBody(data) .setRequestBody(data)
.post(apiUrl + "/netsolid/items/applications", onSuccess) .post(apiUrl + "/netsolid/items/applications", onSuccess)
; ;

View File

@ -143,7 +143,6 @@ var HTTPObject = function() {
break; break;
case "PATCH": case "PATCH":
console.error("Not supported yet: " + method); // TODO
break; break;
default: default:
@ -187,6 +186,29 @@ var HTTPObject = function() {
return this.open("GET", url, false).send(callback); return this.open("GET", url, false).send(callback);
}; };
this.patch = function(url, callback) {
var options = {
type: "PATCH",
headers: this.headers,
url: url,
data: this.requestBody,
contentType: this.contentType,
success: callback
};
if (typeof(window) !== "undefined") {
if (typeof(window.jQuery) !== "undefined") {
window.jQuery.ajax(options);
} else {
console.error("PATCH is required jQuery library");
}
} else {
console.error("PATCH dose not supported on console mode");
}
return this;
};
this.create(); this.create();
}; };