Skip to content
This repository has been archived by the owner on Nov 11, 2023. It is now read-only.

Commit

Permalink
Improve onError types
Browse files Browse the repository at this point in the history
  • Loading branch information
fabien0102 committed Mar 27, 2020
1 parent b30a262 commit 88db463
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import noop from "lodash/noop";
import * as React from "react";
import { ResolveFunction } from "./Get";

export interface RestfulReactProviderProps<T = any> {
export interface RestfulReactProviderProps<TData = any> {
/** The backend URL where the RESTful resources live. */
base: string;
/**
Expand All @@ -14,7 +14,7 @@ export interface RestfulReactProviderProps<T = any> {
* A function to resolve data return from the backend, most typically
* used when the backend response needs to be adapted in some way.
*/
resolve?: ResolveFunction<T>;
resolve?: ResolveFunction<TData>;
/**
* Options passed to the fetch request.
*/
Expand All @@ -26,7 +26,15 @@ export interface RestfulReactProviderProps<T = any> {
* Depending of your case, it can be easier to add a `localErrorOnly` on your `Mutate` component
* to deal with your retry locally instead of in the provider scope.
*/
onError?: (err: any, retry: () => Promise<T | null>, response?: Response) => void;
onError?: (
err: {
message: string;
data: TData | string;
status?: number;
},
retry: () => Promise<TData | null>,
response?: Response,
) => void;
/**
* Any global level query params?
* **Warning:** it's probably not a good idea to put API keys here. Consider headers instead.
Expand Down

0 comments on commit 88db463

Please sign in to comment.