Код: Выделить всё
export const api = createApi({
reducerPath: 'api',
baseQuery: fetchBaseQuery({
baseUrl: '/api/',
prepareHeaders: (headers, api) => {
const { apiSource } = api
// currently want to pass apiSource from the request somewhere,
// then get this value and add it to header
headers.set('api-source', apiSource);
return headers;
},
}),
endpoints: (builder) => ({
getUsers: builder.query({
query: () => `/getUsers`,
}),
}),
});
< /code>
Я хочу, чтобы я мог пройти его из запроса, например: < /p>
// but this is not working now, I can't pass the variable
const { data } = useGetUsers(body, {apiSource})
Есть ли способ этого?
Подробнее здесь: https://stackoverflow.com/questions/796 ... st-headers