getUserData = (userData, criteria) => {
let key = 0;
let items = usersData.map((number) =>
{return {name: number[criteria]}}
);
for (let i of items) {
i.key = key++;
}
return items
};
componentDidMount () {
const userData = ...;
const criteria = ...;
getUserData(userData, criteria)
.then(items => {
console.log(items);
});
}
getUserData = (userData, criteria) => {
let key = 0;
let items = usersData.map((number) =>
{return {name: number[criteria]}}
);
for (let i of items) {
i.key = key++;
}
return items
};
getUserData = (userData, criteria) => {
return new Promise(resolve => {
let key = 0;
let items = usersData.map((number) =>
{return {name: number[criteria]}}
);
for (let i of items) {
i.key = key++;
}
resolve(items)
})
};