ublo-lib 1.21.4 → 1.21.5
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.
|
@@ -7,18 +7,27 @@ const {
|
|
|
7
7
|
} = publicRuntimeConfig;
|
|
8
8
|
const carnetRougeApi = "https://services.carnet-rouge-esf.app/api";
|
|
9
9
|
const authorizationCarnetRouge = "6bdecf9053927dcc7e10923a2cc603a4";
|
|
10
|
-
const fetcher = async (url, body) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
const fetcher = async (url, body, retries = 5) => {
|
|
11
|
+
try {
|
|
12
|
+
const res = await fetch(url, {
|
|
13
|
+
method: "POST",
|
|
14
|
+
headers: {
|
|
15
|
+
...(body ? {
|
|
16
|
+
"content-type": "application/json;charset=utf-8"
|
|
17
|
+
} : {}),
|
|
18
|
+
Authorization: authorizationCarnetRouge
|
|
19
|
+
},
|
|
20
|
+
body: body ? JSON.stringify(body) : undefined
|
|
21
|
+
});
|
|
22
|
+
return res.json();
|
|
23
|
+
} catch (e) {
|
|
24
|
+
if (retries > 0) {
|
|
25
|
+
const plural = retries > 1 ? "s" : "";
|
|
26
|
+
console.warn(`Warning: failed to fetch instructor book ressource "${url}", retrying ${retries} time${plural}...}`);
|
|
27
|
+
return fetcher(url, body, retries - 1);
|
|
28
|
+
}
|
|
29
|
+
throw e;
|
|
30
|
+
}
|
|
22
31
|
};
|
|
23
32
|
export async function fetchInstructors(lang, body = {}) {
|
|
24
33
|
try {
|