Skip to content

Commit cc47642

Browse files
committed
fix: post/page.tsx: handle error cases for getting branches
1 parent 10962ca commit cc47642

File tree

1 file changed

+18
-1
lines changed
  • src/app/(default)/r/[owner]/[repo]/post

1 file changed

+18
-1
lines changed

src/app/(default)/r/[owner]/[repo]/post/page.tsx

+18-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,24 @@ export default function ProductPostPage(){
3434
const {owner, repoName} = context.repoCtx;
3535
setParma({owner,repo: repoName})
3636
const btch = await repo_api.Bhtc(owner, repoName);
37-
const branches = Object.keys(btch).map((value)=>{
37+
if (btch.status !== 200) {
38+
notifications.show({
39+
title: "Error",
40+
message: "Get Branches Error",
41+
color: "red",
42+
})
43+
return;
44+
}
45+
const json:AppWrite<Blob> = JSON.parse(btch.data);
46+
if (json.code !== 200 || !json.data) {
47+
notifications.show({
48+
title: "Error",
49+
message: "Get Branches Error",
50+
color: "red",
51+
})
52+
return;
53+
}
54+
const branches = Object.keys(json.data).map((value)=>{
3855
return JSON.parse(value) as BranchModel
3956
});
4057
for(const idx in branches) {

0 commit comments

Comments
 (0)