Skip to content

Commit

Permalink
fix: properly handle request errors
Browse files Browse the repository at this point in the history
  • Loading branch information
LPkkjHD committed Sep 24, 2024
1 parent a1abe62 commit ed7226a
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions plugins/typescript/src/templates/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,8 @@ export async function ${camel(prefix)}Fetch<
: "Unexpected error"
};
}
throw error;
}
if (response.headers.get('content-type')?.includes('json')) {
else if (response.headers.get('content-type')?.includes('json')) {
return await response.json();
} else {
// if it is not a json response, assume it is a blob and cast it to TData
Expand All @@ -128,6 +125,7 @@ export async function ${camel(prefix)}Fetch<
};
throw errorObject;
}
throw error;
}
const resolveUrl = (
Expand Down

0 comments on commit ed7226a

Please sign in to comment.