次のJSON出力を使用してAPIからデータを取得しようとしています。APIオブジェクトからのデータの抽出
console.log(users)でapiの出力を見ることができるので、データは関数に渡されます。
"data"に含まれる配列を出力しようとしていますが、データにアクセスできないようです。
{
"dataCount": 2,
"data": [
{
"name": "Test review header",
"text": "This is adescription for a test review",
"img": "http://pngimg.com/upload/pigeon_PNG3423.png"
},
{
"name": "Test review header2",
"text": "This is adescription for a test review2",
"img": "http://pngimg.com/upload/pigeon_PNG3422.png"
}
]
}
renderUsers() {
const { users } = this.props;
console.log(users);
Object.keys(users).map(name => users[name])
console.log(users[name]);
};
おそらく、あなたはAPIから受け取ったオブジェクトの一部を提供することができますか? – Jules
私はそれを明確にするために質問を更新しました。クロムではオブジェクトとして表示され、このオブジェクト内のデータ配列にアクセスしようとしています –
は上記のJSONユーザーですか? – paqash