Currently, I am encountering an issue while attempting to type the axios response. Here is a glimpse of how the response type appears:
export interface GetBreedsResponse {
data: {
message: Breed[]
}
}
Within my router file, I have implemented the following code:
router.get("/breeds", async (_req: Request, res: Response) => {
try {
const apiResponse = await axios.get<GetBreedsResponse>("https://url");
let breeds : Breed = await apiResponse.data.message;
// some code
}catch (err: unknown) {
// some code
}
});
An error occurs indicating that the property message
does not exist on GetBreedsResponse
. It seems to be related to the fact that message
is nested inside the data
property, but I am uncertain about how to resolve this.