Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

356
Vistas
How to access the query arguments in transformResponse with redux toolkit query (RTKQ)?

I am making a POST call using the RTK query. I am able to pass the payload data to my query, But I want to access the query arguments 'id' inside my transformResponse function. but found no ways to do so.

below is my code

export const apiSlice = createApi({
  reducerPath: 'api',
  
  baseQuery: fetchBaseQuery({ baseUrl: '/fakeApi' }),
 
  endpoints: builder => ({
    
    getPosts: builder.query({
      
      query: ({id}) => ({ url, method: 'POST', body: { id } }),
      transformResponse: (response) => { console.log(response, id) } //How can I access the 'id' from query here?
    })
  })
})

How can I access the query payload inside the transformResopnse function ?

I also tries passing the arg to transformResponse function but arg is undefined for me.

(response, meta, arg)

arg is undefined for me.

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

Make sure you are using at least the version v1.7.0 of redux-toolkit

Here is the parameters that takes transformResponse

(
  baseQueryReturnValue: unknown,
  meta: unknown,
  arg: unknown
)

You can use:

  • the third argument to get arg that contain your id
transformResponse: (response, meta, arg) => {
  console.log(response, meta, arg)
}
about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda