Skip to content

Commit

Permalink
build: catch init error
Browse files Browse the repository at this point in the history
  • Loading branch information
rowthan committed Jul 20, 2024
1 parent f9625e5 commit fc6f567
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions apps/web/pages/gift.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,26 @@ enum ReceiveStatus {
type UserForm = { uid?: number; email?: string }

export async function getStaticProps() {
const keys = Object.keys(demoGiftDetail).join(',')
const data = await fetch(
`${process.env.API_HOST}/api/graph/book?query=query{gifts{${keys}}}`,
{
headers: {
token: 'system_20231212',
},
}
).then(function (res) {
return res.json()
})

console.log(data, 'static props')

const keys = Object.keys(demoGiftDetail).join(',');
const gifts = [];
try{
const data = await fetch(
`${process.env.API_HOST}/api/graph/book?query=query{gifts{${keys}}}`,
{
headers: {
token: 'system_20231212',
},
}
).then(function (res) {
return res.json()
})
gifts.push(...data?.data?.gifts || [])
}catch (e) {
console.warn('init gifts error')
}
return {
props: {
gifts: data?.data?.gifts || [],
gifts: gifts || [],
},
}
}
Expand Down

0 comments on commit fc6f567

Please sign in to comment.