Skip to content

Commit

Permalink
fix: undici type-error body is unusable
Browse files Browse the repository at this point in the history
  • Loading branch information
johnshift committed Nov 5, 2024
1 parent 561b783 commit 67d4989
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions src/shared/core/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ export class ResponseError extends Error {

async toJSON() {
const contentType = this.res.headers.get('content-type');
const isJson = !!contentType?.includes('application/json');
const body = isJson ? await this.res.json() : await this.res.text();
return {
message: this.message,
info: this.info,
status: this.res.status,
contentType,
body,
};
}
}
Expand Down

0 comments on commit 67d4989

Please sign in to comment.