Sniberb
Sniberb3y ago

⛄ Snowberb ⛄ – 13-38 Jul 4

How can I wait to simultaneous promises but without using Promise.allSettled?
export const getStaticProps: GetStaticProps = async () => {
const { bettingBonuses, casinoBonuses } = getBonuses
const { getAccounts, getTransactions } = getAccountInfo
const bonusPromises = await Promise.allSettled([bettingBonuses(), casinoBonuses()])

const bonuses: IBonus[] = []
const accounts = await getAccounts()
const transactions = await getTransactions()

bonusPromises.forEach(
(promise) => promise.status === 'fulfilled' && bonuses.push(...promise.value)
)

return {
props: {
bonuses,
savedAccounts: accounts,
savedTransactions: transactions,
},
}
}
export const getStaticProps: GetStaticProps = async () => {
const { bettingBonuses, casinoBonuses } = getBonuses
const { getAccounts, getTransactions } = getAccountInfo
const bonusPromises = await Promise.allSettled([bettingBonuses(), casinoBonuses()])

const bonuses: IBonus[] = []
const accounts = await getAccounts()
const transactions = await getTransactions()

bonusPromises.forEach(
(promise) => promise.status === 'fulfilled' && bonuses.push(...promise.value)
)

return {
props: {
bonuses,
savedAccounts: accounts,
savedTransactions: transactions,
},
}
}
I want to load bonuses, accounts and transactions independently of eachother
2 Replies
Sniberb
Sniberb3y ago
My problem is that I need the info for different Tabs in the same page bonuses is needed for the Bets tab, but not for the Accounts tab and viceversa
reactibot
reactibot3y ago
This thread hasn’t had any activity in 12 hours, so it’s now locked. Threads are closed automatically after 12 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/993511126757281862