无法从api到chart.js的值获取,反应js

这是我的api,存储在url中

[
{

"Name": "A",
"X":10
"Y":30
"Z":20
},
{
"Name": "B",
"X":10
"Y":30
"Z":40
},
{
"Name": "C",
"X":10
"Y":30
"Z":10
},

]

我正在尝试将这些值放在堆积图中

enter image description here in this sandbox code, i have tried to take the value of countryRegion from the api, but it appears as undefied in the console. https://codesandbox.io/s/react-chartjs-2-p1gjo

评论
  • 犯小贱~
    犯小贱~ 回复

    看起来您的结构破坏不正确。

    const { data: { countryRegion }, } = await axios.get(changeableUrl);

    在您的api中执行此操作

        const {
          data: countryRegion
        } = await axios.get(changeableUrl);