How map fetch object with - between words in name in react?

After fetch some url i get object with - in name how deal with that???React ignore that object i want map him

What you wanna do is to map out the response.
I don’t know how your data looks like(posted your response and ask what you want out of it!) but you mentioned it was an object, if so it would follow a similar structure to this.

const res = response.map(data => {
  return {
    name: data.name,
    somedata: data.somedata
  }
});

hehe but problem is Screenshot_14
name is life-span :stuck_out_tongue:

So then you’ll just have to point to the “life-span” object into the “name” keyword inside the return statement. In this case I used the key notation rather than the dot notation because there is a hyphen in the name of the “life-span” object.

const res = response.map(data => {
  return {
    name: data["life-span"]
  }
});
1 Like