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

Return empty data in schema #1182

Open
amy-fang opened this issue Oct 22, 2024 · 3 comments
Open

Return empty data in schema #1182

amy-fang opened this issue Oct 22, 2024 · 3 comments
Labels
bug 🔥 Something isn't working

Comments

@amy-fang
Copy link

amy-fang commented Oct 22, 2024

Description

I used interceptors.response.use to return data. When I used Promise.allSettled , it always add en empty data in my response data. The client is '@hey-api/client-axios'. See screenshot.
微信截图_20241022123726

Reproducible example or configuration

OpenAPI specification (optional)

No response

System information (optional)

No response

@amy-fang amy-fang added the bug 🔥 Something isn't working label Oct 22, 2024
Copy link

stackblitz bot commented Oct 22, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@mrlubos
Copy link
Member

mrlubos commented Oct 22, 2024

Hey @amy-fang, can you share a link to the StackBlitz example I believe you've already created?

@amy-fang
Copy link
Author

amy-fang commented Oct 22, 2024

Hey @amy-fang, can you share a link to the StackBlitz example I believe you've already created?

https://stackblitz.com/edit/hey-api-client-axios-example-febun4?file=src%2FApp.tsx

I found that cause this part.

const response = await _axios({
        ...opts,
        data: opts.body,
        params: opts.query,
        url,
      });

      let { data } = response;

      if (opts.responseType === 'json' && opts.responseTransformer) {
        data = await opts.responseTransformer(data);
      }

      return {
        ...response,
        data: data ?? {},
      };

Always return with data. Is there an easy way to package the response data? I want to handler the response data in a global function. But now the axios interceptors don't seem to be the right way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🔥 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants