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

Add fallback value to requests #148

Open
bryanjtc opened this issue Sep 17, 2024 · 1 comment
Open

Add fallback value to requests #148

bryanjtc opened this issue Sep 17, 2024 · 1 comment

Comments

@bryanjtc
Copy link
Contributor

Describe the bug
If a request fails react query throws this error because data cannot be undefined
Query data cannot be undefined. Please make sure to return a value other than undefined from your query function

To Reproduce
Steps to reproduce the behavior:

  1. Use any query generated by this tool and make it throw an error

OpenAPI spec file
If possible, please upload the OpenAPI spec file.

Expected behavior
Allow adding a fallback value like null, or an empty array or empty string

Screenshots
image

  • OS: [e.g. macOS]
  • Version [e.g. v1.0.0]

Additional context
Add any other context about the problem here.

@nickdaugherty
Copy link

I found a workaround - set throwOnError: true in the client options:

import { client } from './api/requests/services.gen.js';

client.setConfig({
    throwOnError: true,
});

The problem is errors aren't being thrown, leading to TanStack Query thinking the request succeeded. Related, the onSuccess() callback is also being incorrectly called as a result of this.

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

No branches or pull requests

2 participants