You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a question, I believe it's currently not possible but if it is, it would be nice to know.
With the fetcherOptions in the apiContext (auto-generated and manually modified) I am able to set some specific headers all of the requests. Let's say, for example, the authentication header which will be common to all requests (ie. Bearer Auth).
There are certain APIs, however, that require their own headers. In those cases, with the parameters of the use* generated function I'm able to send those as well without problem.
However, the problem that happens is that because of the way the fetch fn is called, all these initial fetcherOptions headers seem to get overwritten:
Is there any way to allow it overwrite in a property-specific way? For example something like this:
{headers: {...fetcherOptions.headers, ...variables.headers}} (I know we should check for possible null objects, I'm omitting it for simplicity's sake).
Other way I've been thinking of that could be possible to implement something like this would be passing the variables to the useApiContext() call at the start of each use* function and letting each person to extend the resulting variables in their own fashion or requirements per as the project.
What do you think? Thank you for your help
The text was updated successfully, but these errors were encountered:
bcucumber2
changed the title
Question: extending request headers
Question: extending context initial request headers
Oct 28, 2022
Hi everyone,
I have a question, I believe it's currently not possible but if it is, it would be nice to know.
With the
fetcherOptions
in theapiContext
(auto-generated and manually modified) I am able to set some specific headers all of the requests. Let's say, for example, the authentication header which will be common to all requests (ie. Bearer Auth).There are certain APIs, however, that require their own headers. In those cases, with the parameters of the
use*
generated function I'm able to send those as well without problem.However, the problem that happens is that because of the way the fetch fn is called, all these initial
fetcherOptions
headers seem to get overwritten:myFetchFn({ ...fetcherOptions, ...variables }, signal),
Is there any way to allow it overwrite in a property-specific way? For example something like this:
{headers: {...fetcherOptions.headers, ...variables.headers}}
(I know we should check for possible null objects, I'm omitting it for simplicity's sake).Other way I've been thinking of that could be possible to implement something like this would be passing the variables to the
useApiContext()
call at the start of eachuse*
function and letting each person to extend the resulting variables in their own fashion or requirements per as the project.What do you think? Thank you for your help
The text was updated successfully, but these errors were encountered: