Jak to dzia艂a
U偶yte biblioteki
Wyniki pobierania danych
Ka偶da funkcja, zwraca obiekt w postaci jednego z poni偶szych typ贸w.
G艂贸wny typ wyniku funkcji pobieraj膮cej dane
export type Result<T> = SuccessResult<T> | ErrorResult
export type SuccessResult<T> = {
success: true
data: T
}
export type ErrorResult = ErrorData
export type ErrorData = {
success: false
errorName: ErrorName
cause: unknown
}
Typ wyniku funkcji, kt贸ra pobiera jedn膮 stron臋, np. tablicy
export type PaginationResult = PaginationSuccessResult | PaginationErrorResult
export type PaginationSuccessResult = {
success: true
totalPages: number
}
export type PaginationErrorResult = {} & ErrorData
export type SinglePageResult<T> =
| SinglePageSuccessResult<T>
| SinglePageErrorResult
export type SinglePageSuccessResult<T> = {
success: true
data: T
page: number
}
export type SinglePageErrorResult = {
page: number
} & ErrorData