create request helper methods region
This commit is contained in:
parent
0fc6fd650c
commit
f8297808ec
@ -9,6 +9,7 @@ const url = {
|
|||||||
share: `/api/readonly`
|
share: `/api/readonly`
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//#region request helper methods
|
||||||
function submitForm(form) {
|
function submitForm(form) {
|
||||||
fetch(form.action, {
|
fetch(form.action, {
|
||||||
method: form.method,
|
method: form.method,
|
||||||
@ -35,6 +36,11 @@ function createPost(url, body, contentType = 'application/json') {
|
|||||||
return createRequest('POST', url, body, contentType);
|
return createRequest('POST', url, body, contentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function redirect(url) {
|
||||||
|
return window.location.href = url;
|
||||||
|
}
|
||||||
|
//#endregion
|
||||||
|
|
||||||
function signEnvelope(annotations) {
|
function signEnvelope(annotations) {
|
||||||
return createPost(`/api/annotation`, annotations, contentType)
|
return createPost(`/api/annotation`, annotations, contentType)
|
||||||
}
|
}
|
||||||
@ -43,10 +49,6 @@ function rejectEnvelope(reason) {
|
|||||||
return createPost(url.reject, reason, Content.JSON);
|
return createPost(url.reject, reason, Content.JSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
function redirect(url) {
|
|
||||||
return window.location.href = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
function redirRejected() {
|
function redirRejected() {
|
||||||
return redirect(url.rejectRedir);
|
return redirect(url.rejectRedir);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
function submitForm(n){fetch(n.action,{method:n.method,body:new FormData(n),headers:{"X-Requested-With":"XMLHttpRequest"}})}function createRequest(n,t,i,r="application/json"){return fetch(t,{credentials:"include",method:n,headers:{"Content-Type":r,"X-XSRF-TOKEN":env.xsrfToken},body:JSON.stringify(i)})}function createPost(n,t,i="application/json"){return createRequest("POST",n,t,i)}function signEnvelope(n){return createPost(`/api/annotation`,n,contentType)}function rejectEnvelope(n){return createPost(url.reject,n,Content.JSON)}function redirect(n){return window.location.href=n}function redirRejected(){return redirect(url.rejectRedir)}function shareEnvelope(n,t){return createPost(url.share,{receiverMail:n,dateValid:t},Content.JSON)}const env={xsrfToken:document.getElementsByName("__RequestVerificationToken")[0].value,envKey:document.querySelector('meta[name="env-key"]').getAttribute("content")},url={reject:`/api/annotation/reject`,rejectRedir:`/envelope/${env.envKey}`,share:`/api/readonly`};
|
function submitForm(n){fetch(n.action,{method:n.method,body:new FormData(n),headers:{"X-Requested-With":"XMLHttpRequest"}})}function createRequest(n,t,i,r="application/json"){return fetch(t,{credentials:"include",method:n,headers:{"Content-Type":r,"X-XSRF-TOKEN":env.xsrfToken},body:JSON.stringify(i)})}function createPost(n,t,i="application/json"){return createRequest("POST",n,t,i)}function redirect(n){return window.location.href=n}function signEnvelope(n){return createPost(`/api/annotation`,n,contentType)}function rejectEnvelope(n){return createPost(url.reject,n,Content.JSON)}function redirRejected(){return redirect(url.rejectRedir)}function shareEnvelope(n,t){return createPost(url.share,{receiverMail:n,dateValid:t},Content.JSON)}const env={xsrfToken:document.getElementsByName("__RequestVerificationToken")[0].value,envKey:document.querySelector('meta[name="env-key"]').getAttribute("content")},url={reject:`/api/annotation/reject`,rejectRedir:`/envelope/${env.envKey}`,share:`/api/readonly`};
|
||||||
Loading…
x
Reference in New Issue
Block a user