1const countries = [
2 {"id": 1, "name": "Afghanistan"},
3 {"id": 2, "name": "Albania"},
4 {"id": 3, "name": "Algeria"},
5 {"id": 4, "name": "American Samoa"}
6];
7const transformed = countries.map(({ id, name }) => ({ label: id, value: name }));
8console.log(transformed);
1const countries = [
2 {"id": 1, "name": "Afghanistan"},
3 {"id": 2, "name": "Albania"},
4 {"id": 3, "name": "Algeria"},
5 {"id": 4, "name": "American Samoa"}
6];
7const transformed = countries.map(({ id: label, name: value }) => ({ label, value }));
8console.log(transformed);