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

Feature request: allow configuration of response, only data, or AxiosResponse<data> #143

Open
wimdetroyer opened this issue Aug 11, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@wimdetroyer
Copy link

wimdetroyer commented Aug 11, 2021

Currently, all responses are automatically resolved to axios.response.data, however, sometimes it is useful to have the wrapping AxiosResponse:

export interface AxiosResponse<T = any>  {
  data: T;
  status: number;
  statusText: string;
  headers: any;
  config: AxiosRequestConfig;
  request?: any;
}

For example: say I make a PUT request to create an entity, my API will return a status code 201 with a HTTP location header filled in like: www.example.com/api/v1/entity/123. Having access to this header would make my life a bit easier, however, only the response data is returned now.

I understand this might be an edge case and for 99% of requests, simply returning the data itself is sufficient, but allowing configuration of this might be interesting.

Something like:

export interface ISwaggerOptions = {
 [...]
  methodReturnsWrappedInAxiosResponse: boolean; // Default: false
}
@Manweill
Copy link
Owner

Manweill commented Aug 11, 2021

it mean , you need full axios response?

@wimdetroyer
Copy link
Author

@Manweill Yes.

@Manweill
Copy link
Owner

#144

@Manweill Manweill added the enhancement New feature or request label Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants