Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Type Generics #16

Closed
kaaax0815 opened this issue Sep 3, 2021 · 1 comment · Fixed by #18
Closed

Type Generics #16

kaaax0815 opened this issue Sep 3, 2021 · 1 comment · Fixed by #18

Comments

@kaaax0815
Copy link

Axios supports Type Generics
https://github.com/axios/axios/blob/82c94555917834770bd1389fc0b4cd9ba35ec3fe/index.d.ts#L151
and
https://github.com/axios/axios/blob/82c94555917834770bd1389fc0b4cd9ba35ec3fe/index.d.ts#L83
so if you now the response type you can easily create a interface pass it to the post request like

const data = await axios.post<Result>();

data.data // Autocomplete because `data.data` is `typeof Result`

interface Result {
nice: string;
data: string;
}
@roonie007
Copy link
Owner

I will try to add this as soon as possible

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

Successfully merging a pull request may close this issue.

2 participants