Skip to content

Commit 36774e8

Browse files
committed
[TypeScriptAngular2Client] fixed unnecessary thrown unhandled exceptions with non 204 (http status code) but empty http responses. swagger-api#1334
1 parent 999e2a5 commit 36774e8

File tree

1 file changed

+4
-1
lines changed
  • modules/swagger-codegen/src/main/resources/typescript-angular2

1 file changed

+4
-1
lines changed

modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ export class {{classname}} {
4646
.map((response: Response) => {
4747
if (response.status === 204) {
4848
return undefined;
49-
} else {
49+
}
50+
try {
5051
return response.json() || {};
52+
}catch(e){
53+
return {};
5154
}
5255
});
5356
}

0 commit comments

Comments
 (0)