我想知道如何添加一个console.log in
export const pokemonApi = createApi({
reducerPath: 'pokemonApi',
baseQuery: fetchBaseQuery({ baseUrl: 'https://pokeapi.co/api/v2/' }),
endpoints: (builder) => ({
getPokemonByName: builder.query<Pokemon, string>({
query: (name) => `pokemon/${name}`,
}),
}),
})
这样当组件调用 getPokemonByName 时,它应该 console.log('Hello I am here!')
我在下面尝试过但不起作用并且有编译错误..
getPokemonByName: builder.query<Pokemon, string>({
query: (name) => {`pokemon/${name}`, **console.log('Hello I am here!')**}
}),
https://redux-toolkit.js.org/rtk-query/api/createApi上没有这样的例子
我想这样做是因为我的组件正在尝试调用此方法,但我不确定它是否会到达这里!