Skip to content

Commit

Permalink
fix: add condition for no-content http code
Browse files Browse the repository at this point in the history
This PR adds validation to the response handler to ensure we do not
attempt to parse responses with empty content.
  • Loading branch information
barbmarcio authored Aug 15, 2024
1 parent 2392391 commit a7603c4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import AppError from "./app-error";

class APIClient {
private async handleResponse(response: Response): Promise<unknown> {
const data: unknown = await response.json();
let data: unknown;

if (response.status !== 204) {
data = await response.json();
}

if (!response.ok) {
const retry = response.status === 429 || response.status >= 500;
Expand Down

0 comments on commit a7603c4

Please sign in to comment.