TanStackT
TanStack3y ago
9 replies
standard-azure

Type the api response in useMutation and Usequery

export interface LoginSuccessRes {
    access_token: string
    success: boolean
    token_type: string
}

export interface LoginFailed {
    result: string
    success: boolean
    details: string
}


const navigate = useNavigate()
const { mutateAsync, data: loginresponse } = useMutation<LoginSuccessRes,LoginFailed>({
      mutationFn: loginUser,
})

I was expecting a type matching MutationFunction<LoginSuccessRes, void>, but instead you passed (logindetails: { email: string; password: string; }) => Promise<any> 

what is the right way to type? 
Was this page helpful?