These are chat archives for airbnb/javascript

18th
Sep 2018
Michael Van Der Merwe
@Pheonix929
Sep 18 2018 11:09
Hi guys, a bit new to es6, how would i go about mapping the data object returned by my get request to a class i have created
        m.request({
            method: "GET",
            url: url,
        })
            .then(function (data) {
                let localData = [];
                    for (let i = 0; i < data.length; i++) {
                        let item = data[i];
                        localData.push({
                            id: item.name,
                            label: item.name,
                            parent: null,
                            checkbox: false,
                            secondLevelCheckBox: false,
                            children: 0
                        });
                    }
                selectData.setData(localData);
                selectData.setTotalRootItems(data.length);
            });
I need to map the data returned and replace localData and possibly the for loop with a class i define.