4

I set extraOptions in my endpoint like so :

const myApi = api.injectEndpoints({
  endpoints: builder => ({
      changePassowrd: builder.mutation({
          query: (data) => ({
              url: `${Config.BASE_URL}/users/${data.userId}`,
              method: 'PATCH',
              body: data,
          }),
          extraOptions: () => ({
            myOption: 'Test Option',
          }),
      }),
  })
})

And I try to read extraOptions in prepareHeaders like so:

const baseQuery = fetchBaseQuery({
  baseUrl: Config.BASE_URL,
  prepareHeaders: (headers, {getState, extra}) => {

    console.log('Extra Stuff', extra); // undefined

    return headers;
  },
});

But I'm always getting undefined in the console after triggering the mutation, why is that? Am I using it wrong?

abdou-tech
  • 687
  • 1
  • 8
  • 16

1 Answers1

3

That's redux-thunk's extra, not the endpoint's extraOptions. It seems like fetchBaseQuery generally does not make use of extraOption - a pull request integrating that where necessary is highly welcome.

phry
  • 35,762
  • 5
  • 67
  • 81