Skip to content

Commit

Permalink
fix: empty sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
yongenaelf committed Jul 25, 2024
1 parent c19773c commit 19b0156
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions components/blocks/sheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ export async function Sheet(props: Sheet) {
const range = `${sheetId}!A1:${"ABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(
sheet.grid_properties.column_count - 1
)}${sheet.grid_properties.row_count}`;
const rangeData = await fetcher<{

interface RangeData {
code: number;
data: {
revision: number;
Expand All @@ -83,9 +84,19 @@ export async function Sheet(props: Sheet) {
};
};
msg: string;
}>(
`https://open.larksuite.com/open-apis/sheets/v2/spreadsheets/${tId}/values/${range}`
);
}

let rangeData: RangeData | undefined;

try {
rangeData = await fetcher<RangeData>(
`https://open.larksuite.com/open-apis/sheets/v2/spreadsheets/${tId}/values/${range}`
);
} catch (err) {
console.log(err);
}

if (!rangeData) return null;

const [headerRow, ...rows] = rangeData.data.valueRange.values;

Expand Down

0 comments on commit 19b0156

Please sign in to comment.