Where to add the response type of a Api call inside a custom base Query in RTK query?

1 day ago 1
ARTICLE AD BOX

This is the custom query im using in rtk query the query refreshResult it is for the refresh token so my question is i know what the refreshresult will return

<IApiResponse<RefreshTokenResponse>>

this is the response format so where to add this normally with rtk query we add add what the response will look like while creating the mutation of the query so incase of custom query where to add the response type

const baseQueryWithReauth: BaseQueryFn< string | FetchArgs, unknown, FetchBaseQueryError > = async (args, store, extraOptions) => { let result = await baseQuery(args, store, extraOptions) const refreshToken = (store.getState() as RootState).auth.refreshToken; if (result.error && result.error.status === 401) { if (refreshToken) { const refreshResult = await baseQuery( { url: API_ROUTES.AUTH.REFRESH_TOKEN, method: "POST", body: { refreshToken: refreshToken } }, store, extraOptions ) if (refreshResult.data) { store.dispatch(setNewAccessToken(refreshResult.data as RefreshTokenResponse)) result = await baseQuery(args, store, extraOptions); } else { console.error("Faild to fetch new access token: ", refreshResult.error) store.dispatch(logOut()) } } else { console.warn("no refresh token found logging out"); store.dispatch(logOut()) } } return result }
Read Entire Article