freeze env and url objects
This commit is contained in:
parent
ceff62cb64
commit
2a352265a8
@ -1,14 +1,14 @@
|
|||||||
//#region parameters
|
//#region parameters
|
||||||
const env = {
|
const env = Object.freeze({
|
||||||
xsrfToken: document.getElementsByName('__RequestVerificationToken')[0].value,
|
xsrfToken: document.getElementsByName('__RequestVerificationToken')[0].value,
|
||||||
envKey: document.querySelector('meta[name="env-key"]').getAttribute('content')
|
envKey: document.querySelector('meta[name="env-key"]').getAttribute('content')
|
||||||
}
|
})
|
||||||
|
|
||||||
const url = {
|
const url = Object.freeze({
|
||||||
reject: `/api/annotation/reject`,
|
reject: `/api/annotation/reject`,
|
||||||
rejectRedir: `/envelope/${env.envKey}`,
|
rejectRedir: `/envelope/${env.envKey}`,
|
||||||
share: `/api/readonly`
|
share: `/api/readonly`
|
||||||
};
|
});
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region request helper methods
|
//#region request helper methods
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
function sendRequest(n,t,i=undefined){const r={credentials:"include",method:n,headers:{"X-XSRF-TOKEN":env.xsrfToken}};return i!==undefined&&(r.body=JSON.stringify(i),r.headers["Content-Type"]="application/json"),fetch(t,r)}function getRequest(n){return sendRequest("GET",n)}function postRequest(n,t){return sendRequest("POST",n,t)}function redirect(n){window.location.href=n}function signEnvelope(n){return postRequest(`/api/annotation`,n)}function rejectEnvelope(n){return postRequest(url.reject,n)}function shareEnvelope(n,t){return postRequest(url.share,{receiverMail:n,dateValid:t})}function redirRejected(){redirect(url.rejectRedir)}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 sendRequest(n,t,i=undefined){const r={credentials:"include",method:n,headers:{"X-XSRF-TOKEN":env.xsrfToken}};return i!==undefined&&(r.body=JSON.stringify(i),r.headers["Content-Type"]="application/json"),fetch(t,r)}function getRequest(n){return sendRequest("GET",n)}function postRequest(n,t){return sendRequest("POST",n,t)}function redirect(n){window.location.href=n}function signEnvelope(n){return postRequest(`/api/annotation`,n)}function rejectEnvelope(n){return postRequest(url.reject,n)}function shareEnvelope(n,t){return postRequest(url.share,{receiverMail:n,dateValid:t})}function redirRejected(){redirect(url.rejectRedir)}const env=Object.freeze({xsrfToken:document.getElementsByName("__RequestVerificationToken")[0].value,envKey:document.querySelector('meta[name="env-key"]').getAttribute("content")}),url=Object.freeze({reject:`/api/annotation/reject`,rejectRedir:`/envelope/${env.envKey}`,share:`/api/readonly`});
|
||||||
Loading…
x
Reference in New Issue
Block a user