You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This feature request aims to enhance the usability of interceptors by allowing seamless access to typed data within the interceptor functions.
Expected usage:
ofetch<{id: string;}>("/api",{onResponse({ response }){// Auto complete working with "response._data.id"// or the different property name such as "response.$data.id"},})
Additional information
Would you be willing to help implement this feature?
The text was updated successfully, but these errors were encountered:
87xie
changed the title
Can access the typed data in interceptors
Can access to typed data in interceptors
Mar 27, 2024
Maybe we can consider separating the different context types based on situation, for example:
interfaceFetchOptions<RextendsResponseType=ResponseType,T=any,>extendsOmit<RequestInit,"body">{// ...onRequestError?(context: Pick<FetchContext,'options'|'request'>&{response: undefined;error: Error;}): Promise<void>|void;onResponse?(context: Pick<FetchContext,'options'|'request'>&{response: MappedResponseType<R,T>;error: undefined;}): Promise<void>|void;// ...}ofetch<{id: string;}>("api",{onRequestError({ response, error }){// the error type will be Error// the response type will be undefined},onResponse({ response, error }){// the error type will be undefined// the response type will be "{ id: string; }"},})
Describe the feature
This feature request aims to enhance the usability of interceptors by allowing seamless access to typed data within the interceptor functions.
Expected usage:
Additional information
The text was updated successfully, but these errors were encountered: