Skip to content

Commit

Permalink
[TA-2856] Reject from data on export packages error
Browse files Browse the repository at this point in the history
  • Loading branch information
LaberionAjvazi committed Feb 12, 2024
1 parent 85728d2 commit 9aaba74
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/services/http-client-service.v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,19 @@ class HttpClientServiceV2 {
return new Promise<any>((resolve, reject) => {
axios.get(this.resolveUrl(url), {
headers: this.buildHeaders(contextService.getContext().profile),
responseType: "stream"
responseType: "stream",
validateStatus: status => status >= 200
}).then(response => {
const data: Buffer[] = [];
response.data.on("data", (chunk: Buffer) => {
data.push(chunk);
});
response.data.on("end", () => {
if (this.checkBadRequest(response.status)) {
this.handleBadRequest(response.status, response.data, reject);
} else {
this.handleResponseStreamData(Buffer.concat(data), resolve, reject);
if (response.status !== 200) {
reject(Buffer.concat(data).toString());
}

this.handleResponseStreamData(Buffer.concat(data), resolve, reject);
});
}).catch(err => {
this.handleError(err, resolve, reject);
Expand Down

0 comments on commit 9aaba74

Please sign in to comment.