Accessing "meta" or raw response in Redux-RTK

Viewed 25

Is there a way to access the meta object or the raw response in a query handler?

Eg:

const myApiSlice = createApi({ ... });

const [getFoo, { isFetching }] = myApiSlice.useLazyGetFooQuery();

getFoo({ ...params }).then(res => {
    console.log(res.meta); // <-- "meta" is not available here
});

If there is no way to access neither of these objects, is there a way I can access the response headers (inside the handler, as shown in my example)?

1 Answers

You can access these in transformResponse and use that to add some more info to data, but beyond that, it is not accessible.

Related