#How to do type determination for respons in Axios response interceptor
6 messages · Page 1 of 1 (latest)
!screenshot
`!screenshot`:
Rather than screenshots, please provide either code formatted as:
```ts
// code here
```
Or even better, as an example on the TypeScript playground that is as simple as possible and reproduces the issue. This makes it easier to help you and increases the chances of getting an answer.
the axios methods can take a generic
this way, you can provide the type for the data returned by axios
Preview:```ts
import axios from "axios"
interface MyAPIResponse {
foo: "foo"
bar: {
baz: true
}
}
await axios
.get<MyAPIResponse>("/api")
.then(data => data.data)
.then(data => {
console.log(data.bar.baz) // true
})```
You can choose specific lines to embed by selecting them before copying the link.