@osimatic/helpers-js 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/network.js +3 -13
- package/package.json +1 -1
package/network.js
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
|
|
2
2
|
class HTTPRequest {
|
|
3
|
-
static getHttpHeaders() {
|
|
4
|
-
if (!JwtSession.isAnonymous()) { //on ne définit pas ce header si on ne trouve pas d'access_token
|
|
5
|
-
httpHeaders['Authorization'] = 'Bearer ' + JwtSession.getToken();
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
return httpHeaders;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
3
|
static async get(url, data, successCallback, errorCallback) {
|
|
12
4
|
if (data == null) {
|
|
13
5
|
data = '';
|
|
@@ -56,7 +48,7 @@ class HTTPRequest {
|
|
|
56
48
|
$.ajax({
|
|
57
49
|
type: 'GET',
|
|
58
50
|
url: url + (!url.includes('?') ? '?' : '') + data,
|
|
59
|
-
headers:
|
|
51
|
+
headers: httpHeaders,
|
|
60
52
|
dataType: 'json',
|
|
61
53
|
cache: false,
|
|
62
54
|
success: (data) => successCallback(data),
|
|
@@ -124,7 +116,7 @@ class HTTPRequest {
|
|
|
124
116
|
$.ajax({
|
|
125
117
|
type: 'GET',
|
|
126
118
|
url: url + (!url.includes('?') ? '?' : '') + data,
|
|
127
|
-
headers:
|
|
119
|
+
headers: httpHeaders,
|
|
128
120
|
cache: false,
|
|
129
121
|
xhrFields: {
|
|
130
122
|
responseType: 'blob'
|
|
@@ -191,7 +183,7 @@ class HTTPRequest {
|
|
|
191
183
|
$.ajax({
|
|
192
184
|
type: 'POST',
|
|
193
185
|
url: url,
|
|
194
|
-
headers:
|
|
186
|
+
headers: httpHeaders,
|
|
195
187
|
dataType: 'json', // 22/09/2020 : à voir si cette ligne pose pb (utilisé pour requete import et peut être d'autres
|
|
196
188
|
data: formData,
|
|
197
189
|
cache: false,
|
|
@@ -548,5 +540,3 @@ class UrlAndQueryString {
|
|
|
548
540
|
}
|
|
549
541
|
|
|
550
542
|
}
|
|
551
|
-
|
|
552
|
-
module.exports = { HTTPRequest, Cookie, UrlAndQueryString };
|