mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-03-11 16:35:13 +00:00
Update http.js, app/index.js
This commit is contained in:
parent
a5f60b1409
commit
4ec0d79860
15
app/index.js
15
app/index.js
|
@ -106,18 +106,17 @@ var getLocalApplications = function() {
|
|||
console.log("반영되었습니다.");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
if (applicationId) {
|
||||
req = $.ajax({
|
||||
type: "PATCH",
|
||||
url: apiUrl + "/netsolid/items/applications/" + applicationId,
|
||||
data: JSON.stringify(data),
|
||||
contentType: 'application/json-patch+json',
|
||||
success: onSuccess
|
||||
});
|
||||
HTTP.create()
|
||||
.setContentType("application/json-patch+json")
|
||||
.setRequestBody(JSON.stringify(data))
|
||||
.patch(apiUrl + "/netsolid/items/applications/" + applicationId, onSuccess)
|
||||
;
|
||||
} else {
|
||||
HTTP.create()
|
||||
.setContentType("application/json")
|
||||
.setBearerAuth(token)
|
||||
.setRequestBody(data)
|
||||
.post(apiUrl + "/netsolid/items/applications", onSuccess)
|
||||
;
|
||||
|
|
24
lib/http.js
24
lib/http.js
|
@ -143,7 +143,6 @@ var HTTPObject = function() {
|
|||
break;
|
||||
|
||||
case "PATCH":
|
||||
console.error("Not supported yet: " + method); // TODO
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -187,6 +186,29 @@ var HTTPObject = function() {
|
|||
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();
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user