add prettier & format
This commit is contained in:
@@ -1,66 +1,72 @@
|
||||
class Network {
|
||||
getEnvelope(envelopeKey) {
|
||||
return fetch(`/api/envelope/${envelopeKey}`, this.withCSRFToken({ credentials: "include" }))
|
||||
.then(res => res.json());
|
||||
return fetch(
|
||||
`/api/envelope/${envelopeKey}`,
|
||||
this.withCSRFToken({ credentials: 'include' })
|
||||
).then((res) => res.json())
|
||||
}
|
||||
|
||||
getDocument(envelopeKey, documentId) {
|
||||
return fetch(`/api/document/${envelopeKey}?index=${documentId}`, this.withCSRFToken({ credentials: "include" }))
|
||||
.then(res => res.arrayBuffer());
|
||||
return fetch(
|
||||
`/api/document/${envelopeKey}?index=${documentId}`,
|
||||
this.withCSRFToken({ credentials: 'include' })
|
||||
).then((res) => res.arrayBuffer())
|
||||
}
|
||||
|
||||
postEnvelope(envelopeKey, documentId, jsonString) {
|
||||
const url = `/api/envelope/${envelopeKey}?index=${documentId}`;
|
||||
const url = `/api/envelope/${envelopeKey}?index=${documentId}`
|
||||
const options = {
|
||||
credentials: "include",
|
||||
method: "POST",
|
||||
body: jsonString
|
||||
credentials: 'include',
|
||||
method: 'POST',
|
||||
body: jsonString,
|
||||
}
|
||||
|
||||
console.debug("PostEnvelope/Calling url: " + url)
|
||||
console.debug('PostEnvelope/Calling url: ' + url)
|
||||
return fetch(url, this.withCSRFToken(options))
|
||||
.then(this.handleResponse)
|
||||
.then((res) => {
|
||||
if (!res.ok) {
|
||||
return false;
|
||||
};
|
||||
return true;
|
||||
});
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
postHistory(envelopeKey, actionType) {
|
||||
const url = `/api/history/${envelopeKey}`;
|
||||
const url = `/api/history/${envelopeKey}`
|
||||
|
||||
const data = {
|
||||
actionType: actionType
|
||||
actionType: actionType,
|
||||
}
|
||||
|
||||
const options = {
|
||||
credentials: "include",
|
||||
method: "POST",
|
||||
credentials: 'include',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': "application/json; charset=utf-8"
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
body: JSON.stringify(data),
|
||||
}
|
||||
|
||||
console.debug("PostHistory/Calling url: " + url)
|
||||
console.debug('PostHistory/Calling url: ' + url)
|
||||
return fetch(url, this.withCSRFToken(options))
|
||||
.then(this.handleResponse)
|
||||
.then((res) => {
|
||||
if (!res.ok) {
|
||||
return false;
|
||||
};
|
||||
return true;
|
||||
});
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
withCSRFToken(options) {
|
||||
const token = (document.getElementsByName("__RequestVerificationToken")[0]).value;
|
||||
let headers = options.headers;
|
||||
options.headers = { ...headers, 'X-XSRF-TOKEN': token };
|
||||
const token = document.getElementsByName(
|
||||
'__RequestVerificationToken'
|
||||
)[0].value
|
||||
let headers = options.headers
|
||||
options.headers = { ...headers, 'X-XSRF-TOKEN': token }
|
||||
|
||||
return options;
|
||||
return options
|
||||
}
|
||||
|
||||
handleResponse(res) {
|
||||
@@ -72,4 +78,3 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user