Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: extending context initial request headers #114

Open
bcucumber2 opened this issue Oct 28, 2022 · 2 comments
Open

Question: extending context initial request headers #114

bcucumber2 opened this issue Oct 28, 2022 · 2 comments

Comments

@bcucumber2
Copy link

bcucumber2 commented 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 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:

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 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

@bcucumber2 bcucumber2 changed the title Question: extending request headers Question: extending context initial request headers Oct 28, 2022
@needim
Copy link
Collaborator

needim commented Nov 10, 2022

Hi, sorry but, I didn't understand the issue here. Can you give more context with examples, please?

@dan-cooke
Copy link

@needim explained more in #226

I will get to work on fixing this as its blocking me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants