Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript I';我试图使用json文件,但它可以';不能返回数据_Javascript_Json_Reactjs_Ecmascript 6 - Fatal编程技术网

Javascript I';我试图使用json文件,但它可以';不能返回数据

Javascript I';我试图使用json文件,但它可以';不能返回数据,javascript,json,reactjs,ecmascript-6,Javascript,Json,Reactjs,Ecmascript 6,我是ganna使用这个json 但我得到了错误TypeError:无法读取未定义的属性“aFeeds” 我怎样才能得到这个值 return fetch('https://freemusicarchive.org/featured.json' ) .then(respone => respone.json()) .then(json => console.log(json)) .then(json=> json.aFee

我是ganna使用这个json
但我得到了错误TypeError:无法读取未定义的属性“aFeeds” 我怎样才能得到这个值

  return  fetch('https://freemusicarchive.org/featured.json'
    )
        .then(respone => respone.json())
       .then(json => console.log(json))
        .then(json=> json.aFeeds.aTracks)
        .catch(err=>console.log(err))

因为在第二个
then
中,您没有返回任何内容,因为
console.log
没有返回值。如果要记录它,必须使用函数体并
返回
json

return fetch("https://freemusicarchive.org/featured.json")
    .then(respone => respone.json())
    .then(json => {
        console.log(json);
        return json;
    })
    .then(json => json.aFeeds.aTracks)
    .catch(err => console.log(err));