- updated implementation related to new rejection flow;

This commit is contained in:
Vitalii Kiiko
2025-10-16 15:22:50 +02:00
parent 61389f6c43
commit 8c8737e2ee
8 changed files with 274 additions and 48 deletions

View File

@@ -84,7 +84,6 @@ export class NetworkService {
method: 'POST',
mode: 'cors',
headers: {
//'Content-Type': 'multipart/form-data',
'Authorization': 'Bearer ' + storeGet('getToken'),
},
body: body
@@ -235,6 +234,49 @@ export class NetworkService {
.catch(err => errorCallback(err));
};
static putMultiPart = (url, body, callback, errorCallback, queryParams = null) => {
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: 'PUT',
mode: 'cors',
headers: {
'Authorization': 'Bearer ' + storeGet('getToken'),
},
body: body
})
.then(async response => {
let status = response.status;
this.logApiError(url, status);
return { response: await response.json(), status: status }
})
.then(data => {
if (data.status >= 400 && data.status <= 599) {
errorCallback(data.response)
this.logApiError(url, data.status, data.response);
} else {
callback(data.response)
}
})
.catch(err => errorCallback(err));
};
static isNotBlank(value) {
return value !== null && value !== undefined && value !== ''
}