JS数据结构修改求解


// 获取平台信息
    getPlatformInfo = () => {
        axios({
            url: '/VIID/Feature/GetPlatformInfo',
            method: 'GET'
        }).then((res) => {
            let ipArray = []
            res.data.Data.map((item) => {
                return (
                    ipArray.push({ ip: item.PlatformIp, type: item.PlatformType, Name: item.PlatformName, Port: item.PlatformPort, group: [] })
                )
            })
            console.log('ipArray',ipArray)
            ipArray.forEach(item=>{
                item.group = this.getLibCode(item.ip)
            })
            console.log('ipArray',ipArray)
            setTimeout(()=>{
                this.setState({
                    ResultIpArray: ipArray
                })
            })
        })
    }
    // 获取库和ID
    getLibCode = (value) => {
        axios({
            url: '/VIID/DeliverFeature/GetLibInfo',
            method: 'GET',
            params: {
                PlatformIp: value
            }
        }).then((res)=> {
            if(res.data.ErrCode == 0){
                return res.data.Data
            }
            else{
                return []
            }
        })
    }
// 想要的数据结果
    // ResultIpArray:[
    //     {
    //         ip: '192.169.12.72',
    //         Name: '平台1',
    //         type: '0',
    //         group: [
    //             {
    //                 id: '3',
    //                 Name: '员工库',
    //                 Type: 3
    //             },
    //             ......
    //         ]
    //     },
    //     .....
    // ]

img

img

img

img

你需要改成什么样子?

需要知道后台返回的数据格式是什么样子的,才知道怎么修改数据结构呀

你这两个接口返回数据之间,或者说甚至是表之间都没有映射关系的吗?现在看来这两个接口提供的数据都是相互独立的根据您的说法完全看不出来怎么对应,还是说从上到下一个一个排?