Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/infographic",
"version": "0.2.17",
"version": "0.2.18",
"description": "An Infographic Generation and Rendering Framework, bring words to life!",
"keywords": [
"antv",
Expand Down
2 changes: 2 additions & 0 deletions site/src/components/IconPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ export function IconPageContent() {
});
const response = await fetch(
`https://www.weavefox.cn/api/v1/infographic/icon?${params.toString()}`
);
const result = await response.json();
Comment on lines +263 to +264

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It is a best practice to check the response.ok property before parsing the response body with response.json(). This ensures that the code handles non-200 HTTP status codes (like 404 or 500) gracefully, especially if the server returns a non-JSON error page which would cause response.json() to throw a SyntaxError. Since this call is wrapped in a try-catch block, throwing an error here will be correctly handled by the existing error state logic.

        );
        if (!response.ok) {
          throw new Error(`HTTP error! status: ${response.status}`);
        }
        const result = await response.json();

if (result.success && Array.isArray(result.data)) {
setIcons(result.data);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '0.2.17';
export const VERSION = '0.2.18';
Loading