export const apiSlice = createApi({ reducerPath: 'api', baseQuery: fetchBaseQuery({ baseUrl: API_BASE_URL }), endpoints: ()={}, ==> it throws as error Typescript safety is not met });
请提供任何帮助,我如何添加Typescript安全。
rta7y2nd1#
import { EndpointDefinitions } from '@reduxjs/toolkit/dist/query'; export const apiSlice = createApi({ reducerPath: 'api', baseQuery: fetchBaseQuery({ baseUrl: API_BASE_URL }), endpoints: (): EndpointDefinitions => ({} as EndpointDefinitions), // <=== note here });
这可以通过转换rtk查询终结点类型来修复。
1条答案
按热度按时间rta7y2nd1#
这可以通过转换rtk查询终结点类型来修复。