i'm ganna use this json
but i got error TypeError: Cannot read property 'aFeeds' of undefined How can I get the value?
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))
Because in your second then
, you don't return anything because console.log
doesn't have a return value. If you want to log it, you'd have to use a function body and return
the 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));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.