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

feat(fetch): include status code in fetch client response #1470

Conversation

soartec-lab
Copy link
Member

Status

READY

Description

fix #1465

I updated the 'fetch' client to include the status code in the response, as below:

export type listPetsResponse = {
  status: number;
  data: Pets;
};

export const listPets = async (
  params?: ListPetsParams,
  options?: RequestInit,
): Promise<listPetsResponse> => {
  const res = await fetch(getListPetsUrl(params), {
    ...options,
    method: 'GET',
  });
  const data = await res.json();

  return { status: res.status, data: data };
};

Related PRs

none

Todos

  • Tests
  • Documentation
  • Changelog Entry (unreleased)

Steps to Test or Reproduce

none

@soartec-lab soartec-lab added enhancement New feature or request fetch Fetch client related issue labels Jun 20, 2024
@soartec-lab soartec-lab added this to the 6.31.0 milestone Jun 20, 2024
@soartec-lab
Copy link
Member Author

Errors occurring in CI are fixed in #1471 .

@melloware melloware merged commit 9404af4 into orval-labs:master Jun 20, 2024
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fetch Fetch client related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to handle error response codes with fetch?
2 participants