Replies: 5 comments 4 replies
-
@Zyles Why do you believe this is how you set user agent? |
Beta Was this translation helpful? Give feedback.
-
I don't know. I tried using createClient, but there is something I seriously cannot wrap my head around with this package. I want multiple API clients to different APIs which I generated using the codegen. Some endpoints need authentication and some do not. I created a wrapper like this:
But how do I use this apiClient1 instance in my requests? The demo shows calling the methods directly:
But then I am not using my apiClient1 wrapper, but instead the default client that was generated. Also the demo uses
But using client: to inject a localClient is not supported in the code that got generated for me. What am I missing? |
Beta Was this translation helpful? Give feedback.
-
@Zyles it's hard to say without seeing your code, but my best guess would be you're not setting |
Beta Was this translation helpful? Give feedback.
-
User-agent should be set in the client. Using normal axios client it is as simple as:
It can also be done on a request basis by passing a headers object. Does the fetch client not support this? Looking at the docs I don't understand how to use multiple clients. It mentions configuring a global client. But we have multiple different APIs we need to call and each needs their own client. And how do you use authorization only on endpoints that require it but not the rest? For example this request requires a token (code generated by your lib):
|
Beta Was this translation helpful? Give feedback.
-
I am using Electron and found out I can set the user-agent using their API:
Now the question remains, how to use multiple clients with different config and auth per endpoint? |
Beta Was this translation helpful? Give feedback.
-
Description
How do you set a custom user-agent?
I tried using interceptors but nothing happened:
Beta Was this translation helpful? Give feedback.
All reactions