mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-16 06:31:04 +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("반영되었습니다.");
|
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)
|
||||||
;
|
;
|
||||||
|
|
24
lib/http.js
24
lib/http.js
|
@ -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();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user