SWRConfig changes for swr 2.x

This commit is contained in:
Josh Hawkins 2023-12-07 15:24:45 -06:00
parent 7cf04db975
commit 77a0eb41be

View File

@ -20,8 +20,10 @@ export function ApiProvider({ children, options }: ApiProviderType) {
return (
<SWRConfig
value={{
fetcher: (path, params) =>
axios.get(path, { params }).then((res) => res.data),
fetcher: (key) => {
const [path, params] = Array.isArray(key) ? key : [key, undefined];
return axios.get(path, { params }).then((res) => res.data);
},
...options,
}}
>