useSports
The useSports
hook is used to fetch sports with pre-match and live games.
ℹ️
Hook represents a logic wrapper over TanStack Query's useQuery
hook. Explore TanStack Query docs (opens in a new tab) to understand what data the hook returns.
Usage
import { useSports } from '@azuro-org/sdk'
const { data, isFetching, error } = useSports(props)
Props
{
filter?: {
limit?: number // limit the number of games returned from a query for each sport
sportHub?: SportHub
sportSlug?: string
countrySlug?: string
leagueSlug?: string
sportIds?: Array<string | number>
}
gameOrderBy?: Game_OrderBy.Turnover | Game_OrderBy.StartsAt // default: Game_OrderBy.StartsAt`
orderDir?: OrderDirection // order direction: asc, desc
isLive?: boolean // if `true`, the hook will retrieve live sports
query?: QueryParameter<SportsQuery['sports']> // useQuery params
}
enum SportHub {
Sports = 'sports',
Esports = 'esports',
Unique = 'unique'
}
Return Value
UseQueryResult<SportsQuery['sports']>
import { type UseQueryResult } from '@tanstack/react-query'
type SportsQuery = {
__typename?: 'Query'
sports: Array<{
__typename?: 'Sport'
id: string
slug: string
name: string
sportId: string
turnover: string
countries: Array<{
__typename?: 'Country'
slug: string
name: string
turnover: string
leagues: Array<{
__typename?: 'League'
slug: string
name: string
turnover: string
games: Array<{
__typename?: 'Game'
id: string
gameId: string
slug: string
title: string
startsAt: string
state: Types.GameState
turnover: string
sport: {
__typename?: 'Sport'
sportId: string
slug: string
name: string
sporthub: {
__typename?: 'SportHub'
id: string
slug: string
}
}
league: {
__typename?: 'League'
slug: string
name: string
}
country: {
__typename?: 'Country'
slug: string
name: string
}
participants: Array<{
__typename?: 'Participant'
image?: string | null
name: string
}>
}>
}>
}>
}>
}