Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

162
Visualizações
Logging within createApi redux-toolkit

I am wondering how I can add a console.log with 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}`,
    }),
  }),
})

So that when a component calls getPokemonByName, it should console.log('Hello I am here!')

I have tried below but does not work and has compile error..

  getPokemonByName: builder.query<Pokemon, string>({
   query: (name) => {`pokemon/${name}`, **console.log('Hello I am here!')**}
    }),

There are no examples of this on https://redux-toolkit.js.org/rtk-query/api/createApi

I want to do this because my component is trying to call this method but I am not sure whether it even gets here!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It would be

  getPokemonByName: builder.query<Pokemon, string>({
   query: (name) => {
       console.log('Hello I am here!')
       return `pokemon/${name}`
     },
   }),

But you probably rather should use the Redux Devtools.

There is a new alpha of the Redux Devtools that has even support for RTK Query: https://chrome.google.com/webstore/detail/redux-devtools-next/oamphgegmigmlgkdnijmeomjenbmkbdg

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda