0

I try to use the coinranking api from rapid api but i get a error when a i went to display the 24h volume of a cryptocurrency.

the data is display like this:

  Object
    data:
     coin:
      24hVolume: "21504479215"
     allTimeHigh: {price: '68763.41083248306', timestamp: 1636502400}

but when i type cryptoDetails?.coin.24hVolume

I got a error that say: An identifier or keyword does not follow a numeric identifier.

How i can override this?

Ganzo
  • 198
  • 1
  • 3
  • 16

1 Answers1

1

Numeric identifiers are not allowed in JavaScript. However, you could access to object properties using Bracket Notation.

In the object[property_name] syntax, the property_name is just a string or Symbol. So, it can be any string, including '1foo', '!bar!', or even ' ' (a space).

Like this.

obj.data.coin['24hVolume']
Mirco Bellagamba
  • 950
  • 6
  • 15