floppy-disk 2.10.0-beta.2 → 2.10.0-beta.3

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.
@@ -44,30 +44,31 @@ export const fetcher = (options) => async (...args) => {
44
44
  const res = await fetch(finalUrl, finalOptions);
45
45
  const contentType = res.headers.get('content-type');
46
46
  if (contentType && contentType.includes('application/json')) {
47
- const resJson = await res.json().catch(() => undefined);
48
- if (resJson !== undefined) {
49
- if (query && resJson.errors) {
47
+ let resJson = await res.json();
48
+ if (query) {
49
+ if (resJson.errors) {
50
50
  throw { status: res.status, statusText: res.statusText, response: resJson };
51
51
  }
52
- if (res.ok) {
53
- if (interceptResponse) {
54
- try {
55
- const finalResponse = await interceptResponse(resJson);
56
- return finalResponse;
57
- }
58
- catch (error) {
59
- throw {
60
- status: res.status,
61
- statusText: res.statusText,
62
- response: resJson,
63
- error,
64
- };
65
- }
52
+ resJson = resJson.data;
53
+ }
54
+ if (res.ok) {
55
+ if (interceptResponse) {
56
+ try {
57
+ const finalResponse = await interceptResponse(resJson);
58
+ return finalResponse;
59
+ }
60
+ catch (error) {
61
+ throw {
62
+ status: res.status,
63
+ statusText: res.statusText,
64
+ response: resJson,
65
+ error,
66
+ };
66
67
  }
67
- return resJson;
68
68
  }
69
- throw { status: res.status, statusText: res.statusText, response: resJson };
69
+ return resJson;
70
70
  }
71
+ throw { status: res.status, statusText: res.statusText, response: resJson };
71
72
  }
72
73
  const resText = await res.text().catch(() => undefined);
73
74
  throw { status: res.status, statusText: res.statusText, response: resText };
@@ -47,30 +47,31 @@ const fetcher = (options) => async (...args) => {
47
47
  const res = await fetch(finalUrl, finalOptions);
48
48
  const contentType = res.headers.get('content-type');
49
49
  if (contentType && contentType.includes('application/json')) {
50
- const resJson = await res.json().catch(() => undefined);
51
- if (resJson !== undefined) {
52
- if (query && resJson.errors) {
50
+ let resJson = await res.json();
51
+ if (query) {
52
+ if (resJson.errors) {
53
53
  throw { status: res.status, statusText: res.statusText, response: resJson };
54
54
  }
55
- if (res.ok) {
56
- if (interceptResponse) {
57
- try {
58
- const finalResponse = await interceptResponse(resJson);
59
- return finalResponse;
60
- }
61
- catch (error) {
62
- throw {
63
- status: res.status,
64
- statusText: res.statusText,
65
- response: resJson,
66
- error,
67
- };
68
- }
55
+ resJson = resJson.data;
56
+ }
57
+ if (res.ok) {
58
+ if (interceptResponse) {
59
+ try {
60
+ const finalResponse = await interceptResponse(resJson);
61
+ return finalResponse;
62
+ }
63
+ catch (error) {
64
+ throw {
65
+ status: res.status,
66
+ statusText: res.statusText,
67
+ response: resJson,
68
+ error,
69
+ };
69
70
  }
70
- return resJson;
71
71
  }
72
- throw { status: res.status, statusText: res.statusText, response: resJson };
72
+ return resJson;
73
73
  }
74
+ throw { status: res.status, statusText: res.statusText, response: resJson };
74
75
  }
75
76
  const resText = await res.text().catch(() => undefined);
76
77
  throw { status: res.status, statusText: res.statusText, response: resText };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "floppy-disk",
3
- "version": "2.10.0-beta.2",
3
+ "version": "2.10.0-beta.3",
4
4
  "description": "FloppyDisk - lightweight, simple, and powerful state management library",
5
5
  "keywords": [
6
6
  "state",