具有“任意”值的元组元素的不安全数组解构

问题描述 投票:0回答:0

我正在尝试从模拟的 API 中获取数据并解构数据,但是打字稿抛出错误。这是代码:

  const fetchFlashcards = async (): Promise<IFlashcards[]> => {
  const { data } = await axios.get(`${url.flashcards}`);
  return data as IFlashcards[];
  };

{数据}发生错误。

打字稿错误:

具有

any
值的元组元素的不安全数组解构。

知道如何解决这个问题吗?

reactjs typescript destructuring react-query
© www.soinside.com 2019 - 2024. All rights reserved.