-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Sample Request Generation #86
Comments
The request file is used to override the default request file that is generated by @hey-api/openapi-ts You'll only need a custom request file to override the default handling of requests. If you only want to change the baseUrl and headers then I recommend not supplying a request file and modifying the OpenAPI singleton constant that is used for each request, it is exported from |
Oh, Thank you. Do you want me to modify the OpenAPI in the file directly or create another file that modifies it? |
import the constant into your runtime and modify it before setting up the react app. /** main.tsx */
import { OpenAPI as OpenAPIConfig } from './openapi/requests/core/OpenAPI';
...
OpenAPIConfig.BASE = 'www.domain.com/api';
OpenAPIConfig.HEADERS = {
'X-Header1': 'header-1'
'X-Header2': 'header-2'
};
...
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<QueryClientProvider client={queryClient}>
<App />
</QueryClientProvider>
</React.StrictMode>
); |
Oh, I see; thank you. I use Next 14, so I will just update the layout.tsx |
Opened PR #88 to add info in readme. |
@seriouslag @7nohe just wanted to add that if you are using nextJS, to set the OpenAPIConfig you need to put it inside a 'use client' provider(or depending on your project your provider root) |
Thanks for the info. |
Hi, I really like this project, but I have an issue with the sample request on the example project.
It gets a bit confusing on how it works:
I want to ask how the request generation should work or am I using it incorrectly?
The text was updated successfully, but these errors were encountered: