@findatruck/convex-client 0.2.1 → 0.2.2

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.cjs CHANGED
@@ -116,11 +116,12 @@ var ConvexClient = class {
116
116
  body: JSON.stringify(body)
117
117
  });
118
118
  if (!response.ok) {
119
+ const responseText = await response.text();
119
120
  let responseBody;
120
121
  try {
121
- responseBody = await response.json();
122
+ responseBody = JSON.parse(responseText);
122
123
  } catch {
123
- responseBody = await response.text();
124
+ responseBody = responseText;
124
125
  }
125
126
  throw new ConvexClientError(
126
127
  `Request to ${path} failed with status ${response.status}`,
@@ -151,11 +152,12 @@ var ConvexClient = class {
151
152
  response = await this.attemptFetch(url, method, body, perAttemptTimeoutMs);
152
153
  if (response.ok) return;
153
154
  if (!retryOnStatuses.includes(response.status)) {
155
+ const responseText = await response.text();
154
156
  let responseBody;
155
157
  try {
156
- responseBody = await response.json();
158
+ responseBody = JSON.parse(responseText);
157
159
  } catch {
158
- responseBody = await response.text();
160
+ responseBody = responseText;
159
161
  }
160
162
  throw new ConvexClientError(
161
163
  `Request to ${path} failed with status ${response.status}`,
@@ -171,11 +173,12 @@ var ConvexClient = class {
171
173
  }
172
174
  if (attempt >= maxAttempts) {
173
175
  if (response) {
176
+ const responseText = await response.text();
174
177
  let responseBody;
175
178
  try {
176
- responseBody = await response.json();
179
+ responseBody = JSON.parse(responseText);
177
180
  } catch {
178
- responseBody = await response.text();
181
+ responseBody = responseText;
179
182
  }
180
183
  throw new ConvexClientError(
181
184
  `Request to ${path} failed after ${attempt} attempts with status ${response.status}`,
package/dist/index.js CHANGED
@@ -83,11 +83,12 @@ var ConvexClient = class {
83
83
  body: JSON.stringify(body)
84
84
  });
85
85
  if (!response.ok) {
86
+ const responseText = await response.text();
86
87
  let responseBody;
87
88
  try {
88
- responseBody = await response.json();
89
+ responseBody = JSON.parse(responseText);
89
90
  } catch {
90
- responseBody = await response.text();
91
+ responseBody = responseText;
91
92
  }
92
93
  throw new ConvexClientError(
93
94
  `Request to ${path} failed with status ${response.status}`,
@@ -118,11 +119,12 @@ var ConvexClient = class {
118
119
  response = await this.attemptFetch(url, method, body, perAttemptTimeoutMs);
119
120
  if (response.ok) return;
120
121
  if (!retryOnStatuses.includes(response.status)) {
122
+ const responseText = await response.text();
121
123
  let responseBody;
122
124
  try {
123
- responseBody = await response.json();
125
+ responseBody = JSON.parse(responseText);
124
126
  } catch {
125
- responseBody = await response.text();
127
+ responseBody = responseText;
126
128
  }
127
129
  throw new ConvexClientError(
128
130
  `Request to ${path} failed with status ${response.status}`,
@@ -138,11 +140,12 @@ var ConvexClient = class {
138
140
  }
139
141
  if (attempt >= maxAttempts) {
140
142
  if (response) {
143
+ const responseText = await response.text();
141
144
  let responseBody;
142
145
  try {
143
- responseBody = await response.json();
146
+ responseBody = JSON.parse(responseText);
144
147
  } catch {
145
- responseBody = await response.text();
148
+ responseBody = responseText;
146
149
  }
147
150
  throw new ConvexClientError(
148
151
  `Request to ${path} failed after ${attempt} attempts with status ${response.status}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@findatruck/convex-client",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",