mahyuan / Front_end_basics

Anything I can note here about studying
MIT License
1 stars 0 forks source link

for...of遍历请求数据 #14

Open mahyuan opened 5 years ago

mahyuan commented 5 years ago
let arr = [{
    id: 11,
    name: 'name1',
    age: 22
}, {
    id: 23,
    name: 'name1',
    age: 22
}, {
    id: 29,
    name: 'name1',
    age: 22
}]

async getEveryDetail() {
    if (arr.length > 0) {
        for (const [index, value] of arr.entries()) {
            let res = await fetch(value.id)
            value.info = res.data.info
        }
    }
}