@swan-admin/swan-ai-measurements 1.0.79 → 1.0.81

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/utils.ts +11 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swan-admin/swan-ai-measurements",
3
- "version": "1.0.79",
3
+ "version": "1.0.81",
4
4
  "description": "provides ai measurement suggestion",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/esm/index.js",
package/src/utils.ts CHANGED
@@ -24,12 +24,18 @@ export async function fetchData(options: FetchDataOptions): Promise<any> {
24
24
 
25
25
  const apiUrl = `${baseUrl}${path}${queryParams ? `?${new URLSearchParams(queryParams)}` : ""}`;
26
26
  try {
27
- const res: AxiosResponse<any> = await axios.post(apiUrl, body, { headers });
28
- if (res.status >= 200 && res.status < 300) {
29
- return res.data;
27
+ const response = await fetch(apiUrl, {
28
+ method: "POST",
29
+ headers,
30
+ body: JSON.stringify(body),
31
+ });
32
+
33
+ if (!response.ok) {
34
+ throw new Error(`Error: Unexpected response status ${response.status}`);
30
35
  }
31
- console.error(`Error: Unexpected response status ${res.status}`);
32
- return {};
36
+
37
+ const data = await response.json();
38
+ return data;
33
39
  } catch (error) {
34
40
  console.error(error, "while uploading");
35
41
  return {};