@pretto/places 0.42.0 → 0.43.0

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/dist/index.js CHANGED
@@ -53,9 +53,20 @@ const DEFAULT_DEBOUNCE_TIME = 300;
53
53
  let getDelayedData = null;
54
54
  const fetchData = (url, signal) => __awaiter(void 0, void 0, void 0, function* () {
55
55
  try {
56
- const response = yield fetch(url, { signal });
56
+ const response = yield fetch(url, {
57
+ signal,
58
+ headers: {
59
+ Accept: 'application/json',
60
+ 'Content-Type': 'application/json',
61
+ },
62
+ mode: 'cors',
63
+ credentials: 'omit',
64
+ cache: 'no-cache',
65
+ redirect: 'follow',
66
+ referrerPolicy: 'no-referrer',
67
+ });
57
68
  if (!response.ok) {
58
- throw new Error('Error: ' + response.status);
69
+ throw new Error(`Erreur HTTP: ${response.status} - ${response.statusText}`);
59
70
  }
60
71
  return response;
61
72
  }
@@ -63,6 +74,9 @@ const fetchData = (url, signal) => __awaiter(void 0, void 0, void 0, function* (
63
74
  if (error instanceof DOMException && error.name === 'AbortError') {
64
75
  return new Promise(() => { });
65
76
  }
77
+ if (error instanceof Error) {
78
+ throw new Error(`Erreur lors de la requête: ${error.message}`);
79
+ }
66
80
  throw error;
67
81
  }
68
82
  });
@@ -1 +1 @@
1
- {"version":3,"file":"customFetch.d.ts","sourceRoot":"","sources":["../../src/lib/customFetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAwB9C,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAC3G,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAA"}
1
+ {"version":3,"file":"customFetch.d.ts","sourceRoot":"","sources":["../../src/lib/customFetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAsC9C,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAC3G,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAA"}
package/dist/module.js CHANGED
@@ -45,9 +45,20 @@ const DEFAULT_DEBOUNCE_TIME = 300;
45
45
  let getDelayedData = null;
46
46
  const fetchData = (url, signal) => __awaiter(void 0, void 0, void 0, function* () {
47
47
  try {
48
- const response = yield fetch(url, { signal });
48
+ const response = yield fetch(url, {
49
+ signal,
50
+ headers: {
51
+ Accept: 'application/json',
52
+ 'Content-Type': 'application/json',
53
+ },
54
+ mode: 'cors',
55
+ credentials: 'omit',
56
+ cache: 'no-cache',
57
+ redirect: 'follow',
58
+ referrerPolicy: 'no-referrer',
59
+ });
49
60
  if (!response.ok) {
50
- throw new Error('Error: ' + response.status);
61
+ throw new Error(`Erreur HTTP: ${response.status} - ${response.statusText}`);
51
62
  }
52
63
  return response;
53
64
  }
@@ -55,6 +66,9 @@ const fetchData = (url, signal) => __awaiter(void 0, void 0, void 0, function* (
55
66
  if (error instanceof DOMException && error.name === 'AbortError') {
56
67
  return new Promise(() => { });
57
68
  }
69
+ if (error instanceof Error) {
70
+ throw new Error(`Erreur lors de la requête: ${error.message}`);
71
+ }
58
72
  throw error;
59
73
  }
60
74
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pretto/places",
3
- "version": "0.42.0",
3
+ "version": "0.43.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",