Thomas - Stitax
08/03/2021, 8:22 PMWickey
08/03/2021, 8:28 PMThomas - Stitax
08/03/2021, 8:33 PMasync function getRandomQuote() {
try {
const { data, count } = await supabase
.from<definitions['quotes']>('quotes')
.select(`
quote,
songs (
listen_url,
title,
albums (
cover_url,
name
)
)
`, { count: 'exact'})
const randomQuoteId = getRandomId(0, count!)
return data![randomQuoteId]
}
catch(error) {
console.error(error)
return error
};
}
function getRandomId(min: number, max: number){
return Math.floor(Math.random()*(max-min+1)+min)
}
export default getRandomQuote
Thomas - Stitax
08/03/2021, 8:35 PMKosh
08/03/2021, 8:50 PMKosh
08/03/2021, 8:50 PMKosh
08/03/2021, 8:50 PMsilentworks
08/03/2021, 9:23 PMThomas - Stitax
08/03/2021, 9:35 PMsilentworks
08/03/2021, 9:37 PMsilentworks
08/03/2021, 9:39 PMThomas - Stitax
08/03/2021, 9:43 PM