Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I change items key spelling. Given key spelling is 'id' and 'name' #78

Open
YaserMb opened this issue Oct 9, 2021 · 0 comments

Comments

@YaserMb
Copy link

YaserMb commented Oct 9, 2021

const items = [
// name key is must. It is to show the text in front
{id: 1, name: 'twitter'},
{id: 2, name: 'codepen'},
{id: 3, name: 'envelope'},
{id: 4, name: 'etsy'},
{id: 5, name: 'facebook'},
{id: 6, name: 'foursquare'},
{id: 7, name: 'github-alt'},
{id: 8, name: 'github'},
{id: 9, name: 'gitlab'},
{id: 10, name: 'instagram'},
];

Above is items object with key as 'id' and 'name'
The list which I am getting from API has different key. How do I change that?

I want like this:
const items = [
// name key is must. It is to show the text in front
{bike_id: 1, bike_number: 'twitter'},
{bike_id: 2, bike_number: 'codepen'},
{bike_id: 3, bike_number: 'envelope'},
{bike_id: 4, bike_number: 'etsy'},
{bike_id: 5, bike_number: 'facebook'},
{bike_id: 6, bike_number: 'foursquare'},
{bike_id: 7, bike_number: 'github-alt'},
{bike_id: 8, bike_number: 'github'},
{bike_id: 9, bike_number: 'gitlab'},
{bike_id: 10, bike_number: 'instagram'},
];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant