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
- const res = await fetch(url, {
12
- method: "POST",
13
- headers: {
14
- ...(body ? {
15
- "content-type": "application/json;charset=utf-8"
16
- } : {}),
17
- Authorization: authorizationCarnetRouge
18
- },
19
- body: body ? JSON.stringify(body) : undefined
20
- });
21
- return res.json();
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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ublo-lib",
3
- "version": "1.21.4",
3
+ "version": "1.21.5",
4
4
  "peerDependencies": {
5
5
  "dt-design-system": "^3.1.5",
6
6
  "leaflet": "^1.9.1",