- added login page;
- added file upload; - added faq item edit modal;
This commit is contained in:
@@ -85,6 +85,47 @@ export class NetworkService {
|
||||
.catch(err => errorCallback(err));
|
||||
};
|
||||
|
||||
static postMultiPart = (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': 'multipart/form-data',
|
||||
'Authorization': 'Bearer ' + storeGet.main.getToken(),
|
||||
},
|
||||
body: body
|
||||
})
|
||||
.then(async response => {
|
||||
let status = response.status;
|
||||
return { response: await response.json(), 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) => {
|
||||
fetch(url, {
|
||||
method: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user