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.