This is the data I fetch through an API:
{ "0x5af2be193a6abca9c8817001f45744777db30756": { "usd": 0.11039 }}
but when I try to access the data to put in html using:
var price = data.0x5af2be193a6abca9c8817001f45744777db30756.usd;
The error reads back:
Uncaught SyntaxError: Invalid or unexpected token
I think it is bc it doesn't identify 0x5af2be193a6abca9c8817001f45744777db30756
as a string but I don't know how to fix it.
data["0x5af2be193a6abca9c8817001f45744777db30756"].usd;instead, however it's probably not a good idea to be hard coding such strange keys in your code, perhaps you want to loop over the data such as with afor in ...loop.