I am trying RTK Query for the first time to fetch some data in a react + ts application. Is there a way where I could specify some default data if the API fails? What is the good practice that should be followed here?
export const dummyApi = createApi({
reducerPath: dummyApi ,
baseQuery,
tagTypes: [ Dummy ],
endpoints: (builder) => ({
getDummy: builder.query<DummyItem[], void>({
query: () => `/dummy`,
providesTags: [ Dummy ],
transformResponse: (response: DummyApiResponse) =>
return [...someDefaultListOfItems, ...response.data];
},
}),
}),
});
我在<代码>transformErrorResponse中尝试过一些东西,但可以查到。