- added add company page;

- connected api for delega download, upload and deleting;
This commit is contained in:
Vitalii Kiiko
2024-10-09 17:33:06 +02:00
parent b139825b47
commit 8cac4ea23e
11 changed files with 547 additions and 71 deletions

View File

@@ -126,6 +126,47 @@ export class NetworkService {
.catch(err => errorCallback(err));
};
static postBlob = (url, body, callback, errorCallback, queryParams) => {
if (queryParams) {
url += '?'
for (let i = 0; i < queryParams.length; i++) {
if (queryParams[i] && this.isNotBlank(queryParams[i][0]) && this.isNotBlank(queryParams[i][1])) {
let param = queryParams[i][0] + '=' + queryParams[i][1]
if (i !== queryParams.length - 1)
param += '&'
url += param;
}
}
if (url.charAt(url.length) === '&')
url = url.substring(0, url.length - 1);
}
fetch(url, {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + storeGet.main.getToken(),
},
body: JSON.stringify(body)
})
.then(async response => {
let status = response.status;
return { response: await response.blob(), status: status }
})
.then(data => {
if (data.status >= 400 && data.status <= 599)
errorCallback(data.response)
else
callback(data.response)
})
.catch(err => errorCallback(err));
};
static unauthorizedPost = (url, body, callback, errorCallback, queryParams) => {
if (queryParams) {
url += '?'