Skip to content

Commit 83575f6

Browse files
committed
chore: update structure
1 parent a89d34f commit 83575f6

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

templates/node/src/client.ts.twig

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ class Client {
263263
const { uri, options } = this.prepareRequest(method, url, headers, params);
264264

265265
let data: any = null;
266-
let text: string = '';
267266

268267
const response = await fetch(uri, options);
269268

@@ -274,18 +273,16 @@ class Client {
274273

275274
if (response.headers.get('content-type')?.includes('application/json')) {
276275
data = await response.json();
277-
text = JSON.stringify(data);
278276
} else if (responseType === 'arrayBuffer') {
279277
data = await response.arrayBuffer();
280278
} else {
281-
text = await response.text();
282279
data = {
283-
message: text
280+
message: await response.text();
284281
};
285282
}
286283

287284
if (400 <= response.status) {
288-
throw new {{spec.title | caseUcfirst}}Exception(data?.message, response.status, data?.type, text);
285+
throw new {{spec.title | caseUcfirst}}Exception(data?.message, response.status, data?.type, JSON.stringify(data));
289286
}
290287

291288
return data;

templates/react-native/src/client.ts.twig

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,6 @@ class Client {
414414

415415
try {
416416
let data = null;
417-
let text: string = '';
418417

419418
const response = await fetch(url.toString(), options);
420419

@@ -425,16 +424,14 @@ class Client {
425424

426425
if (response.headers.get('content-type')?.includes('application/json')) {
427426
data = await response.json();
428-
text = JSON.stringify(data);
429427
} else {
430-
text = await response.text();
431428
data = {
432-
message: text
429+
message: await response.text()
433430
};
434431
}
435432

436433
if (400 <= response.status) {
437-
throw new {{spec.title | caseUcfirst}}Exception(data?.message, response.status, data?.type, text);
434+
throw new {{spec.title | caseUcfirst}}Exception(data?.message, response.status, data?.type, JSON.stringify(data));
438435
}
439436

440437
const cookieFallback = response.headers.get('X-Fallback-Cookies');

templates/web/src/client.ts.twig

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,6 @@ class Client {
669669
const { uri, options } = this.prepareRequest(method, url, headers, params);
670670

671671
let data: any = null;
672-
let text: string = '';
673672

674673
const response = await fetch(uri, options);
675674

@@ -680,18 +679,16 @@ class Client {
680679

681680
if (response.headers.get('content-type')?.includes('application/json')) {
682681
data = await response.json();
683-
text = JSON.stringify(data);
684682
} else if (responseType === 'arrayBuffer') {
685683
data = await response.arrayBuffer();
686684
} else {
687-
text = await response.text();
688685
data = {
689-
message: text
686+
message: await response.text();
690687
};
691688
}
692689

693690
if (400 <= response.status) {
694-
throw new {{spec.title | caseUcfirst}}Exception(data?.message, response.status, data?.type, text);
691+
throw new {{spec.title | caseUcfirst}}Exception(data?.message, response.status, data?.type, JSON.stringify(data));
695692
}
696693

697694
const cookieFallback = response.headers.get('X-Fallback-Cookies');

0 commit comments

Comments
 (0)