我正在尝试使用打字稿进行反应查询教程,但是在获取数据时发生了错误。
代码:
type heroType = {
id: number;
name: string;
alterEgo: string;
};
function QueryDataFetch() {
const fetchdata = ()=>{ return axios.get("http://localhost:8000/superheroes")}
const { isLoading, data ,error} = useQuery<heroType[]>(["heros"],fetchdata);
Run Code Online (Sandbox Code Playgroud)
此错误红色 unline 显示在fetchdata
数据:
[
{
"id": 1,
"name": "Batman",
"alterEgo": "Bruce Wayne"
},
{
"id": 2,
"name": "Superman",
"alterEgo": "Clark Kent"
},
{
"id": 3,
"name": "Wonder Woman",
"alterEgo": "Princess Diana"
}
]
Run Code Online (Sandbox Code Playgroud)
错误:
TS2769: No overload matches this call.
The last overload gave the following error.
Argument of …Run Code Online (Sandbox Code Playgroud)